Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/hana/fwd/core/make.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*!
0002 @file
0003 Forward declares `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_FWD_CORE_MAKE_HPP
0011 #define BOOST_HANA_FWD_CORE_MAKE_HPP
0012 
0013 #include <boost/hana/config.hpp>
0014 
0015 
0016 namespace boost { namespace hana {
0017     //! @ingroup group-core
0018     //! Create an object of the given tag with the given arguments.
0019     //!
0020     //! This function serves the same purpose as constructors in usual C++.
0021     //! However, instead of creating an object of a specific C++ type, it
0022     //! creates an object of a specific tag, regardless of the C++ type
0023     //! of that object.
0024     //!
0025     //! This function is actually a variable template, so `make<T>` can be
0026     //! passed around as a function object creating an object of tag `T`.
0027     //! Also, it uses tag-dispatching so this is how it should be customized
0028     //! for user-defined tags.
0029     //!
0030     //! Finally, the default implementation of `make` is equivalent to calling
0031     //! the constructor of the given tag with the corresponding arguments.
0032     //! In other words, by default,
0033     //! @code
0034     //!     make<T>(args...) == T(args...)
0035     //! @endcode
0036     //!
0037     //! Note that the arguments are perfectly forwarded and the form of
0038     //! construction which is used is exactly as documented, i.e. `T(args...)`.
0039     //! However, if `T(args...)` is not a valid expression, a compilation
0040     //! error is triggered. This default behavior is useful because it makes
0041     //! foreign C++ types that have no notion of tag constructible with `make`
0042     //! out-of-the-box, since their tag is exactly themselves.
0043     //!
0044     //!
0045     //! Example
0046     //! -------
0047     //! @include example/core/make.cpp
0048 #ifdef BOOST_HANA_DOXYGEN_INVOKED
0049     template <typename Tag>
0050     constexpr auto make = [](auto&& ...x) -> decltype(auto) {
0051         return tag-dispatched;
0052     };
0053 #else
0054     template <typename Tag, typename = void>
0055     struct make_impl;
0056 
0057     template <typename Tag>
0058     struct make_t {
0059         template <typename ...X>
0060         constexpr decltype(auto) operator()(X&& ...x) const {
0061             return make_impl<Tag>::apply(static_cast<X&&>(x)...);
0062         }
0063     };
0064 
0065     template <typename Tag>
0066     BOOST_HANA_INLINE_VARIABLE constexpr make_t<Tag> make{};
0067 #endif
0068 }} // end namespace boost::hana
0069 
0070 #endif // !BOOST_HANA_FWD_CORE_MAKE_HPP