3 Defines `boost::hana::make`.
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_CORE_MAKE_HPP
11 #define BOOST_HANA_CORE_MAKE_HPP
13 #include <boost/hana/fwd/core/make.hpp>
15 #include <boost/hana/config.hpp>
16 #include <boost/hana/core/default.hpp>
17 #include <boost/hana/core/when.hpp>
20 BOOST_HANA_NAMESPACE_BEGIN
22 template <typename Datatype, typename>
23 struct make_impl : make_impl<Datatype, when<true>> { };
26 template <typename Datatype, bool condition>
27 struct make_impl<Datatype, when<condition>> : default_ {
28 template <typename ...X>
29 static constexpr auto make_helper(int, X&& ...x)
30 -> decltype(Datatype(static_cast<X&&>(x)...))
31 { return Datatype(static_cast<X&&>(x)...); }
33 template <typename ...X>
34 static constexpr auto make_helper(long, X&& ...) {
35 static_assert((sizeof...(X), false),
36 "there exists no constructor for the given data type");
39 template <typename ...X>
40 static constexpr decltype(auto) apply(X&& ...x)
41 { return make_helper(int{}, static_cast<X&&>(x)...); }
43 BOOST_HANA_NAMESPACE_END
45 #endif // !BOOST_HANA_CORE_MAKE_HPP