3 Forward declares `boost::hana::make`.
5 @copyright Louis Dionne 2013-2017
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_FWD_CORE_MAKE_HPP
11 #define BOOST_HANA_FWD_CORE_MAKE_HPP
13 #include <boost/hana/config.hpp>
16 BOOST_HANA_NAMESPACE_BEGIN
17 //! @ingroup group-core
18 //! Create an object of the given tag with the given arguments.
20 //! This function serves the same purpose as constructors in usual C++.
21 //! However, instead of creating an object of a specific C++ type, it
22 //! creates an object of a specific tag, regardless of the C++ type
25 //! This function is actually a variable template, so `make<T>` can be
26 //! passed around as a function object creating an object of tag `T`.
27 //! Also, it uses tag-dispatching so this is how it should be customized
28 //! for user-defined tags.
30 //! Finally, the default implementation of `make` is equivalent to calling
31 //! the constructor of the given tag with the corresponding arguments.
32 //! In other words, by default,
34 //! make<T>(args...) == T(args...)
37 //! Note that the arguments are perfectly forwarded and the form of
38 //! construction which is used is exactly as documented, i.e. `T(args...)`.
39 //! However, if `T(args...)` is not a valid expression, a compilation
40 //! error is triggered. This default behavior is useful because it makes
41 //! foreign C++ types that have no notion of tag constructible with `make`
42 //! out-of-the-box, since their tag is exactly themselves.
47 //! @include example/core/make.cpp
48 #ifdef BOOST_HANA_DOXYGEN_INVOKED
49 template <typename Tag>
50 constexpr auto make = [](auto&& ...x) -> decltype(auto) {
51 return tag-dispatched;
54 template <typename Tag, typename = void>
57 template <typename Tag>
59 template <typename ...X>
60 constexpr decltype(auto) operator()(X&& ...x) const {
61 return make_impl<Tag>::apply(static_cast<X&&>(x)...);
65 template <typename Tag>
66 constexpr make_t<Tag> make{};
68 BOOST_HANA_NAMESPACE_END
70 #endif // !BOOST_HANA_FWD_CORE_MAKE_HPP