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