Remove copy and copy assignment rather than have them as private declarations.
They are superfluous given the move and move assignment.
As a drive-by, also specialize `std::hash` without reopening `namespace std`.
Differential Revision: https://reviews.llvm.org/D118502
{
MoveOnly mo[] = {MoveOnly{3}};
// expected-error@array:* {{to_array requires copy constructible elements}}
- // expected-error@array:* {{calling a private constructor}}
+ // expected-error@array:* {{call to implicitly-deleted copy constructor of 'MoveOnly'}}
std::to_array(mo); // expected-note {{requested here}}
}
{
const MoveOnly cmo[] = {MoveOnly{3}};
// expected-error@array:* {{to_array requires move constructible elements}}
- // expected-error@array:* {{calling a private constructor}}
+ // expected-error@array:* {{call to implicitly-deleted copy constructor of 'MoveOnly'}}
std::to_array(std::move(cmo)); // expected-note {{requested here}}
}
class MoveOnly
{
- MoveOnly(const MoveOnly&);
- MoveOnly& operator=(const MoveOnly&);
-
int data_;
public:
constexpr MoveOnly(int data = 1) : data_(data) {}
friend void operator,(T t, U u) = delete;
};
-namespace std {
template <>
-struct hash<MoveOnly>
+struct std::hash<MoveOnly>
{
typedef MoveOnly argument_type;
typedef size_t result_type;
constexpr size_t operator()(const MoveOnly& x) const {return x.get();}
};
-}
-
#endif // TEST_STD_VER >= 11
#endif // MOVEONLY_H