1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 #include "test_macros.h"
14 #if TEST_STD_VER >= 11
21 MoveOnly(const MoveOnly
&);
22 MoveOnly
& operator=(const MoveOnly
&);
26 constexpr MoveOnly(int data
= 1) : data_(data
) {}
27 TEST_CONSTEXPR_CXX14
MoveOnly(MoveOnly
&& x
)
28 : data_(x
.data_
) {x
.data_
= 0;}
29 TEST_CONSTEXPR_CXX14 MoveOnly
& operator=(MoveOnly
&& x
)
30 {data_
= x
.data_
; x
.data_
= 0; return *this;}
32 constexpr int get() const {return data_
;}
34 constexpr bool operator==(const MoveOnly
& x
) const {return data_
== x
.data_
;}
35 constexpr bool operator< (const MoveOnly
& x
) const {return data_
< x
.data_
;}
36 TEST_CONSTEXPR_CXX14 MoveOnly
operator+(const MoveOnly
& x
) const
37 { return MoveOnly
{data_
+ x
.data_
}; }
38 TEST_CONSTEXPR_CXX14 MoveOnly
operator*(const MoveOnly
& x
) const
39 { return MoveOnly
{data_
* x
.data_
}; }
47 typedef MoveOnly argument_type
;
48 typedef size_t result_type
;
49 constexpr std::size_t operator()(const MoveOnly
& x
) const {return x
.get();}
54 #endif // TEST_STD_VER >= 11