]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/include/boost/hana/detail/has_common_embedding.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / detail / has_common_embedding.hpp
1 /*!
2 @file
3 Defines `boost::hana::detail::has_[nontrivial_]common_embedding`.
4
5 @copyright Louis Dionne 2013-2016
6 Distributed under the Boost Software License, Version 1.0.
7 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
8 */
9
10 #ifndef BOOST_HANA_DETAIL_HAS_COMMON_EMBEDDING_HPP
11 #define BOOST_HANA_DETAIL_HAS_COMMON_EMBEDDING_HPP
12
13 #include <boost/hana/config.hpp>
14 #include <boost/hana/core/common.hpp>
15 #include <boost/hana/core/to.hpp>
16 #include <boost/hana/detail/void_t.hpp>
17
18 #include <type_traits>
19
20
21 BOOST_HANA_NAMESPACE_BEGIN namespace detail {
22 template <template <typename...> class Concept, typename T, typename U, typename = void>
23 struct has_common_embedding_impl : std::false_type { };
24
25 template <template <typename...> class Concept, typename T, typename U>
26 struct has_common_embedding_impl<Concept, T, U, detail::void_t<
27 typename common<T, U>::type
28 >> {
29 using Common = typename common<T, U>::type;
30 using type = std::integral_constant<bool,
31 Concept<T>::value &&
32 Concept<U>::value &&
33 Concept<Common>::value &&
34 is_embedded<T, Common>::value &&
35 is_embedded<U, Common>::value
36 >;
37 };
38
39 //! @ingroup group-details
40 //! Returns whether `T` and `U` both have an embedding into a
41 //! common type.
42 //!
43 //! If `T` and `U` do not have a common-type, this metafunction returns
44 //! false.
45 template <template <typename...> class Concept, typename T, typename U>
46 using has_common_embedding = typename has_common_embedding_impl<Concept, T, U>::type;
47
48 template <template <typename...> class Concept, typename T, typename U>
49 struct has_nontrivial_common_embedding_impl
50 : has_common_embedding_impl<Concept, T, U>
51 { };
52
53 template <template <typename...> class Concept, typename T>
54 struct has_nontrivial_common_embedding_impl<Concept, T, T>
55 : std::false_type
56 { };
57
58 //! @ingroup group-details
59 //! Returns whether `T` and `U` are distinct and both have an embedding
60 //! into a common type.
61 //!
62 //! If `T` and `U` do not have a common-type, this metafunction returns
63 //! false.
64 template <template <typename...> class Concept, typename T, typename U>
65 using has_nontrivial_common_embedding =
66 typename has_nontrivial_common_embedding_impl<Concept, T, U>::type;
67 } BOOST_HANA_NAMESPACE_END
68
69 #endif // !BOOST_HANA_DETAIL_HAS_COMMON_EMBEDDING_HPP