3 Defines `boost::hana::detail::has_[nontrivial_]common_embedding`.
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)
10 #ifndef BOOST_HANA_DETAIL_HAS_COMMON_EMBEDDING_HPP
11 #define BOOST_HANA_DETAIL_HAS_COMMON_EMBEDDING_HPP
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>
18 #include <type_traits>
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 { };
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
29 using Common = typename common<T, U>::type;
30 using type = std::integral_constant<bool,
33 Concept<Common>::value &&
34 is_embedded<T, Common>::value &&
35 is_embedded<U, Common>::value
39 //! @ingroup group-details
40 //! Returns whether `T` and `U` both have an embedding into a
43 //! If `T` and `U` do not have a common-type, this metafunction returns
45 template <template <typename...> class Concept, typename T, typename U>
46 using has_common_embedding = typename has_common_embedding_impl<Concept, T, U>::type;
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>
53 template <template <typename...> class Concept, typename T>
54 struct has_nontrivial_common_embedding_impl<Concept, T, T>
58 //! @ingroup group-details
59 //! Returns whether `T` and `U` are distinct and both have an embedding
60 //! into a common type.
62 //! If `T` and `U` do not have a common-type, this metafunction returns
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
69 #endif // !BOOST_HANA_DETAIL_HAS_COMMON_EMBEDDING_HPP