File indexing completed on 2025-01-18 09:37:40
0001
0002
0003
0004
0005
0006
0007
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
0022 template <typename Datatype, typename>
0023 struct make_impl : make_impl<Datatype, when<true>> { };
0024
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 }}
0044
0045 #endif