]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/type/is_valid.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/assert.hpp>
6 #include <boost/hana/not.hpp>
7 #include <boost/hana/type.hpp>
11 namespace hana
= boost::hana
;
15 // Checking for a member
16 struct Person
{ std::string name
; };
17 auto has_name
= hana::is_valid([](auto&& p
) -> decltype((void)p
.name
) { });
20 static_assert(has_name(joe
), "");
21 static_assert(!has_name(1), "");
24 // Checking for a nested type
25 auto has_value_type
= hana::is_valid([](auto t
) -> hana::type
<
26 typename
decltype(t
)::type::value_type
29 static_assert(has_value_type(hana::type_c
<std::vector
<int>>), "");
30 static_assert(!has_value_type(hana::type_c
<Person
>), "");