Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:52:46

0001 /*!
0002 @file
0003 Defines `boost::hana::detail::has_[nontrivial_]common_embedding`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Distributed under the Boost Software License, Version 1.0.
0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
0008  */
0009 
0010 #ifndef BOOST_HANA_DETAIL_HAS_COMMON_EMBEDDING_HPP
0011 #define BOOST_HANA_DETAIL_HAS_COMMON_EMBEDDING_HPP
0012 
0013 #include <boost/hana/config.hpp>
0014 #include <boost/hana/core/common.hpp>
0015 #include <boost/hana/core/to.hpp>
0016 #include <boost/hana/detail/void_t.hpp>
0017 
0018 #include <type_traits>
0019 
0020 
0021 namespace boost { namespace hana { namespace detail {
0022     template <template <typename...> class Concept, typename T, typename U, typename = void>
0023     struct has_common_embedding_impl : std::false_type { };
0024 
0025     template <template <typename...> class Concept, typename T, typename U>
0026     struct has_common_embedding_impl<Concept, T, U, detail::void_t<
0027         typename common<T, U>::type
0028     >> {
0029         using Common = typename common<T, U>::type;
0030         using type = std::integral_constant<bool,
0031             Concept<T>::value &&
0032             Concept<U>::value &&
0033             Concept<Common>::value &&
0034             is_embedded<T, Common>::value &&
0035             is_embedded<U, Common>::value
0036         >;
0037     };
0038 
0039     //! @ingroup group-details
0040     //! Returns whether `T` and `U` both have an embedding into a
0041     //! common type.
0042     //!
0043     //! If `T` and `U` do not have a common-type, this metafunction returns
0044     //! false.
0045     template <template <typename...> class Concept, typename T, typename U>
0046     using has_common_embedding = typename has_common_embedding_impl<Concept, T, U>::type;
0047 
0048     template <template <typename...> class Concept, typename T, typename U>
0049     struct has_nontrivial_common_embedding_impl
0050         : has_common_embedding_impl<Concept, T, U>
0051     { };
0052 
0053     template <template <typename...> class Concept, typename T>
0054     struct has_nontrivial_common_embedding_impl<Concept, T, T>
0055         : std::false_type
0056     { };
0057 
0058     //! @ingroup group-details
0059     //! Returns whether `T` and `U` are distinct and both have an embedding
0060     //! into a common type.
0061     //!
0062     //! If `T` and `U` do not have a common-type, this metafunction returns
0063     //! false.
0064     template <template <typename...> class Concept, typename T, typename U>
0065     using has_nontrivial_common_embedding =
0066         typename has_nontrivial_common_embedding_impl<Concept, T, U>::type;
0067 } }} // end namespace boost::hana
0068 
0069 #endif // !BOOST_HANA_DETAIL_HAS_COMMON_EMBEDDING_HPP