]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/asio/traits/static_require.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / asio / traits / static_require.hpp
CommitLineData
20effc67
TL
1//
2// traits/static_require.hpp
3// ~~~~~~~~~~~~~~~~~~~~~~~~~
4//
5// Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6//
7// Distributed under the Boost Software License, Version 1.0. (See accompanying
8// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9//
10
11#ifndef BOOST_ASIO_TRAITS_STATIC_REQUIRE_HPP
12#define BOOST_ASIO_TRAITS_STATIC_REQUIRE_HPP
13
14#if defined(_MSC_VER) && (_MSC_VER >= 1200)
15# pragma once
16#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18#include <boost/asio/detail/config.hpp>
19#include <boost/asio/detail/type_traits.hpp>
20#include <boost/asio/traits/static_query.hpp>
21
22#if defined(BOOST_ASIO_HAS_DECLTYPE) \
23 && defined(BOOST_ASIO_HAS_NOEXCEPT)
24# define BOOST_ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT 1
25#endif // defined(BOOST_ASIO_HAS_DECLTYPE)
26 // && defined(BOOST_ASIO_HAS_NOEXCEPT)
27
28#include <boost/asio/detail/push_options.hpp>
29
30namespace boost {
31namespace asio {
32namespace traits {
33
34template <typename T, typename Property, typename = void>
35struct static_require_default;
36
37template <typename T, typename Property, typename = void>
38struct static_require;
39
40} // namespace traits
41namespace detail {
42
43struct no_static_require
44{
45 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = false);
46};
47
48template <typename T, typename Property, typename = void>
49struct static_require_trait :
50 conditional<
51 is_same<T, typename decay<T>::type>::value
52 && is_same<Property, typename decay<Property>::type>::value,
53 no_static_require,
54 traits::static_require<
55 typename decay<T>::type,
56 typename decay<Property>::type>
57 >::type
58{
59};
60
61#if defined(BOOST_ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT)
62
63#if defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
64
65template <typename T, typename Property>
66struct static_require_trait<T, Property,
67 typename enable_if<
68 decay<Property>::type::value() == traits::static_query<T, Property>::value()
69 >::type>
70{
71 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
72};
73
74#else // defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
75
76false_type static_require_test(...);
77
78template <typename T, typename Property>
79true_type static_require_test(T*, Property*,
80 typename enable_if<
81 Property::value() == traits::static_query<T, Property>::value()
82 >::type* = 0);
83
84template <typename T, typename Property>
85struct has_static_require
86{
87 BOOST_ASIO_STATIC_CONSTEXPR(bool, value =
88 decltype((static_require_test)(
89 static_cast<T*>(0), static_cast<Property*>(0)))::value);
90};
91
92template <typename T, typename Property>
93struct static_require_trait<T, Property,
94 typename enable_if<
95 has_static_require<typename decay<T>::type,
96 typename decay<Property>::type>::value
97 >::type>
98{
99 BOOST_ASIO_STATIC_CONSTEXPR(bool, is_valid = true);
100};
101
102#endif // defined(BOOST_ASIO_HAS_WORKING_EXPRESSION_SFINAE)
103
104#endif // defined(BOOST_ASIO_HAS_DEDUCED_STATIC_REQUIRE_TRAIT)
105
106} // namespace detail
107namespace traits {
108
109template <typename T, typename Property, typename>
110struct static_require_default : detail::static_require_trait<T, Property>
111{
112};
113
114template <typename T, typename Property, typename>
115struct static_require : static_require_default<T, Property>
116{
117};
118
119} // namespace traits
120} // namespace asio
121} // namespace boost
122
123#include <boost/asio/detail/pop_options.hpp>
124
125#endif // BOOST_ASIO_TRAITS_STATIC_REQUIRE_HPP