Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:37:40

0001 /*!
0002 @file
0003 Defines `boost::hana::make`.
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_CORE_MAKE_HPP
0011 #define BOOST_HANA_CORE_MAKE_HPP
0012 
0013 #include <boost/hana/fwd/core/make.hpp>
0014 
0015 #include <boost/hana/config.hpp>
0016 #include <boost/hana/core/default.hpp>
0017 #include <boost/hana/core/when.hpp>
0018 
0019 
0020 namespace boost { namespace hana {
0021     //! @cond
0022     template <typename Datatype, typename>
0023     struct make_impl : make_impl<Datatype, when<true>> { };
0024     //! @endcond
0025 
0026     template <typename Datatype, bool condition>
0027     struct make_impl<Datatype, when<condition>> : default_ {
0028         template <typename ...X>
0029         static constexpr auto make_helper(int, X&& ...x)
0030             -> decltype(Datatype(static_cast<X&&>(x)...))
0031         { return Datatype(static_cast<X&&>(x)...); }
0032 
0033         template <typename ...X>
0034         static constexpr auto make_helper(long, X&& ...) {
0035             static_assert(((void) sizeof...(X), false),
0036             "there exists no constructor for the given data type");
0037         }
0038 
0039         template <typename ...X>
0040         static constexpr decltype(auto) apply(X&& ...x)
0041         { return make_helper(int{}, static_cast<X&&>(x)...); }
0042     };
0043 }} // end namespace boost::hana
0044 
0045 #endif // !BOOST_HANA_CORE_MAKE_HPP