]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/test/map/cnstr.default.cpp
1 // Copyright Louis Dionne 2013-2017
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 #include <boost/hana/bool.hpp>
6 #include <boost/hana/fwd/hash.hpp>
7 #include <boost/hana/map.hpp>
8 #include <boost/hana/pair.hpp>
9 #include <boost/hana/type.hpp>
11 #include <type_traits>
12 namespace hana
= boost::hana
;
17 NoDefault(NoDefault
const&) = default;
18 constexpr explicit NoDefault(int) { }
21 auto operator==(NoDefault
const&, NoDefault
const&) { return hana::true_c
; }
22 auto operator!=(NoDefault
const&, NoDefault
const&) { return hana::false_c
; }
24 // Note: It is also useful to check with a non-empty class, because that
25 // triggers different instantiations due to EBO.
26 struct NoDefault_nonempty
{
27 NoDefault_nonempty() = delete;
28 NoDefault_nonempty(NoDefault_nonempty
const&) = default;
29 constexpr explicit NoDefault_nonempty(int k
) : i(k
) { }
33 auto operator==(NoDefault_nonempty
const&, NoDefault_nonempty
const&) { return hana::true_c
; }
34 auto operator!=(NoDefault_nonempty
const&, NoDefault_nonempty
const&) { return hana::false_c
; }
38 Default(Default
const&) = default;
39 constexpr explicit Default(int) { }
42 auto operator==(Default
const&, Default
const&) { return hana::true_c
; }
43 auto operator!=(Default
const&, Default
const&) { return hana::false_c
; }
45 namespace boost
{ namespace hana
{
47 struct hash_impl
<NoDefault
> {
48 static constexpr auto apply(NoDefault
const&)
49 { return hana::type_c
<NoDefault
>; };
53 struct hash_impl
<NoDefault_nonempty
> {
54 static constexpr auto apply(NoDefault_nonempty
const&)
55 { return hana::type_c
<NoDefault_nonempty
>; };
59 struct hash_impl
<Default
> {
60 static constexpr auto apply(Default
const&)
61 { return hana::type_c
<Default
>; };
66 auto map1
= hana::make_map(hana::make_pair(Default(1), Default(1)));
67 static_assert(std::is_default_constructible
<decltype(map1
)>::value
, "");
69 auto map2
= hana::make_map(hana::make_pair(NoDefault(1), NoDefault(1)));
70 static_assert(!std::is_default_constructible
<decltype(map2
)>::value
, "");
72 auto map3
= hana::make_map(hana::make_pair(NoDefault_nonempty(1), NoDefault_nonempty(1)));
73 static_assert(!std::is_default_constructible
<decltype(map3
)>::value
, "");