]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/example/type/is_valid.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / example / type / is_valid.cpp
CommitLineData
b32b8144 1// Copyright Louis Dionne 2013-2017
7c673cae
FG
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)
4
5#include <boost/hana/assert.hpp>
6#include <boost/hana/not.hpp>
7#include <boost/hana/type.hpp>
8
9#include <string>
10#include <vector>
11namespace hana = boost::hana;
12
13
14int main() {
15 // Checking for a member
16 struct Person { std::string name; };
17 auto has_name = hana::is_valid([](auto&& p) -> decltype((void)p.name) { });
18
19 Person joe{"Joe"};
20 static_assert(has_name(joe), "");
21 static_assert(!has_name(1), "");
22
23
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
27 > { });
28
29 static_assert(has_value_type(hana::type_c<std::vector<int>>), "");
30 static_assert(!has_value_type(hana::type_c<Person>), "");
31}