1 // Copyright Louis Dionne 2013-2016
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
5 #ifndef TEST_SUPPORT_CONSTEXPR_MOVE_ONLY_HPP
6 #define TEST_SUPPORT_CONSTEXPR_MOVE_ONLY_HPP
8 #include <boost/hana/bool.hpp>
9 #include <boost/hana/fwd/hash.hpp>
10 #include <boost/hana/type.hpp>
15 // A move-only type that's also a literal type. It is also Comparable and
16 // Hashable so it can be used in associative containers.
18 struct ConstexprMoveOnly {
19 constexpr ConstexprMoveOnly() { }
20 constexpr ConstexprMoveOnly(ConstexprMoveOnly const&) = delete;
21 constexpr ConstexprMoveOnly& operator=(ConstexprMoveOnly const&) = delete;
22 constexpr ConstexprMoveOnly(ConstexprMoveOnly&&) { }
25 template <int i, int j>
26 constexpr auto operator==(ConstexprMoveOnly<i> const&, ConstexprMoveOnly<j> const&)
27 { return boost::hana::bool_c<i == j>; }
29 template <int i, int j>
30 constexpr auto operator!=(ConstexprMoveOnly<i> const&, ConstexprMoveOnly<j> const&)
31 { return boost::hana::bool_c<i != j>; }
33 namespace boost { namespace hana {
35 struct hash_impl<ConstexprMoveOnly<i>> {
36 static constexpr auto apply(ConstexprMoveOnly<i> const&)
37 { return hana::type_c<ConstexprMoveOnly<i>>; };
41 #endif // !TEST_SUPPORT_CONSTEXPR_MOVE_ONLY_HPP