12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- #ifndef BOOST_HANA_FUNCTIONAL_APPLY_HPP
- #define BOOST_HANA_FUNCTIONAL_APPLY_HPP
- #include <boost/hana/config.hpp>
- namespace boost { namespace hana {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- #ifdef BOOST_HANA_DOXYGEN_INVOKED
- constexpr auto apply = [](auto&& f, auto&& ...x) -> decltype(auto) {
- return forwarded(f)(forwarded(x)...);
- };
- #else
- struct apply_t {
- template <typename F, typename... Args>
- constexpr auto operator()(F&& f, Args&&... args) const ->
- decltype(static_cast<F&&>(f)(static_cast<Args&&>(args)...))
- {
- return static_cast<F&&>(f)(static_cast<Args&&>(args)...);
- }
- template <typename Base, typename T, typename Derived>
- constexpr auto operator()(T Base::*pmd, Derived&& ref) const ->
- decltype(static_cast<Derived&&>(ref).*pmd)
- {
- return static_cast<Derived&&>(ref).*pmd;
- }
- template <typename PMD, typename Pointer>
- constexpr auto operator()(PMD pmd, Pointer&& ptr) const ->
- decltype((*static_cast<Pointer&&>(ptr)).*pmd)
- {
- return (*static_cast<Pointer&&>(ptr)).*pmd;
- }
- template <typename Base, typename T, typename Derived, typename... Args>
- constexpr auto operator()(T Base::*pmf, Derived&& ref, Args&&... args) const ->
- decltype((static_cast<Derived&&>(ref).*pmf)(static_cast<Args&&>(args)...))
- {
- return (static_cast<Derived&&>(ref).*pmf)(static_cast<Args&&>(args)...);
- }
- template <typename PMF, typename Pointer, typename... Args>
- constexpr auto operator()(PMF pmf, Pointer&& ptr, Args&& ...args) const ->
- decltype(((*static_cast<Pointer&&>(ptr)).*pmf)(static_cast<Args&&>(args)...))
- {
- return ((*static_cast<Pointer&&>(ptr)).*pmf)(static_cast<Args&&>(args)...);
- }
- };
- BOOST_HANA_INLINE_VARIABLE constexpr apply_t apply{};
- #endif
- }}
- #endif
|