Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:15

0001 /*=============================================================================
0002     Copyright (c) 2015 Paul Fultz II
0003     decay.h
0004     Distributed under the Boost Software License, Version 1.0. (See accompanying
0005     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 ==============================================================================*/
0007 
0008 #ifndef BOOST_HOF_GUARD_DECAY_H
0009 #define BOOST_HOF_GUARD_DECAY_H
0010 
0011 /// decay
0012 /// =====
0013 /// 
0014 /// Description
0015 /// -----------
0016 /// 
0017 /// The `decay` function is a unary function object that returns whats given to it after decaying its type.
0018 /// 
0019 /// Synopsis
0020 /// --------
0021 /// 
0022 ///     struct
0023 ///     {
0024 ///         template<class T>
0025 ///         constexpr typename decay<T>::type operator()(T&& x) const
0026 ///         {
0027 ///             return boost::hof::forward<T>(x);
0028 ///         }
0029 ///     } decay;
0030 /// 
0031 /// References
0032 /// ----------
0033 /// 
0034 /// * [n3255](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3255.html) - Proposal for `decay_copy`
0035 /// 
0036 
0037 #include <boost/hof/detail/delegate.hpp>
0038 #include <boost/hof/detail/unwrap.hpp>
0039 #include <boost/hof/detail/static_const_var.hpp>
0040 #include <boost/hof/detail/forward.hpp>
0041 
0042 namespace boost { namespace hof { namespace detail {
0043 
0044 template<class T>
0045 struct decay_mf
0046 : unwrap_reference<typename std::decay<T>::type>
0047 {};
0048 
0049 struct decay_f
0050 {
0051     template<
0052         class T, 
0053         class Result=typename unwrap_reference<typename std::decay<T>::type>::type, 
0054         class=typename std::enable_if<(BOOST_HOF_IS_CONSTRUCTIBLE(Result, T))>::type
0055     >
0056     constexpr Result operator()(T&& x) const BOOST_HOF_NOEXCEPT_CONSTRUCTIBLE(Result, T&&)
0057     {
0058         return BOOST_HOF_FORWARD(T)(x);
0059     }
0060 };
0061 
0062 }
0063 
0064 BOOST_HOF_DECLARE_STATIC_VAR(decay, detail::decay_f);
0065 
0066 }} // namespace boost::hof
0067 
0068 #endif