]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/hash.cpp
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 #include <boost/hana/assert.hpp>
6 #include <boost/hana/equal.hpp>
7 #include <boost/hana/hash.hpp>
8 #include <boost/hana/integral_constant.hpp>
9 #include <boost/hana/type.hpp>
11 #include <type_traits>
13 namespace hana
= boost::hana
;
16 // Sample implementation of a compile-time set data structure. Of course,
17 // this naive implementation only works when no two elements of the same
18 // set have the same hash.
22 template <typename
...T
>
24 : bucket
<typename
decltype(hana::hash(std::declval
<T
>()))::type
>...
27 template <typename Set
, typename T
>
30 bucket
<typename
decltype(hana::hash(std::declval
<T
>()))::type
>,
35 using Set
= set
<hana::int_
<1>, hana::ulong
<2>, hana::type
<char>>;
37 static_assert(contains
<Set
, hana::int_
<1>>{}, "");
38 static_assert(contains
<Set
, hana::ulong
<2>>{}, "");
39 static_assert(contains
<Set
, hana::type
<char>>{}, "");
41 static_assert(!contains
<Set
, hana::int_
<3>>{}, "");
42 static_assert(!contains
<Set
, hana::type
<float>>{}, "");