File indexing completed on 2025-01-18 09:37:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_HANA_FUNCTIONAL_APPLY_HPP
0011 #define BOOST_HANA_FUNCTIONAL_APPLY_HPP
0012
0013 #include <boost/hana/config.hpp>
0014
0015
0016 namespace boost { namespace hana {
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039 #ifdef BOOST_HANA_DOXYGEN_INVOKED
0040 constexpr auto apply = [](auto&& f, auto&& ...x) -> decltype(auto) {
0041 return forwarded(f)(forwarded(x)...);
0042 };
0043 #else
0044 struct apply_t {
0045 template <typename F, typename... Args>
0046 constexpr auto operator()(F&& f, Args&&... args) const ->
0047 decltype(static_cast<F&&>(f)(static_cast<Args&&>(args)...))
0048 {
0049 return static_cast<F&&>(f)(static_cast<Args&&>(args)...);
0050 }
0051
0052 template <typename Base, typename T, typename Derived>
0053 constexpr auto operator()(T Base::*pmd, Derived&& ref) const ->
0054 decltype(static_cast<Derived&&>(ref).*pmd)
0055 {
0056 return static_cast<Derived&&>(ref).*pmd;
0057 }
0058
0059 template <typename PMD, typename Pointer>
0060 constexpr auto operator()(PMD pmd, Pointer&& ptr) const ->
0061 decltype((*static_cast<Pointer&&>(ptr)).*pmd)
0062 {
0063 return (*static_cast<Pointer&&>(ptr)).*pmd;
0064 }
0065
0066 template <typename Base, typename T, typename Derived, typename... Args>
0067 constexpr auto operator()(T Base::*pmf, Derived&& ref, Args&&... args) const ->
0068 decltype((static_cast<Derived&&>(ref).*pmf)(static_cast<Args&&>(args)...))
0069 {
0070 return (static_cast<Derived&&>(ref).*pmf)(static_cast<Args&&>(args)...);
0071 }
0072
0073 template <typename PMF, typename Pointer, typename... Args>
0074 constexpr auto operator()(PMF pmf, Pointer&& ptr, Args&& ...args) const ->
0075 decltype(((*static_cast<Pointer&&>(ptr)).*pmf)(static_cast<Args&&>(args)...))
0076 {
0077 return ((*static_cast<Pointer&&>(ptr)).*pmf)(static_cast<Args&&>(args)...);
0078 }
0079 };
0080
0081 BOOST_HANA_INLINE_VARIABLE constexpr apply_t apply{};
0082 #endif
0083 }}
0084
0085 #endif