]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/example/tutorial/concepts.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / example / tutorial / concepts.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/core/default.hpp>
6#include <boost/hana/core/tag_of.hpp>
b32b8144 7#include <boost/hana/integral_constant.hpp>
7c673cae
FG
8
9#include <string>
10#include <type_traits>
11namespace hana = boost::hana;
12
13
14namespace with_special_base_class {
15//! [special_base_class]
16struct special_base_class { };
17
18template <typename T>
19struct print_impl : special_base_class {
20 template <typename ...Args>
21 static constexpr auto apply(Args&& ...) = delete;
22};
23
24template <typename T>
b32b8144
FG
25struct Printable
26 : hana::integral_constant<bool,
27 !std::is_base_of<special_base_class, print_impl<hana::tag_of_t<T>>>::value
28 >
29{ };
7c673cae
FG
30//! [special_base_class]
31
32//! [special_base_class_customize]
33struct Person { std::string name; };
34
35template <>
36struct print_impl<Person> /* don't inherit from special_base_class */ {
37 // ... implementation ...
38};
39
40static_assert(Printable<Person>::value, "");
41static_assert(!Printable<void>::value, "");
42//! [special_base_class_customize]
43}
44
45namespace actual {
46//! [actual]
47template <typename T>
48struct print_impl : hana::default_ {
49 template <typename ...Args>
50 static constexpr auto apply(Args&& ...) = delete;
51};
52
53template <typename T>
b32b8144
FG
54struct Printable
55 : hana::integral_constant<bool,
56 !hana::is_default<print_impl<hana::tag_of_t<T>>>::value
57 >
58{ };
7c673cae
FG
59//! [actual]
60
61static_assert(!Printable<void>::value, "");
62}
63
64int main() { }