/*============================================================================= Copyright (c) 2011-2013 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_FUNCTIONAL_PTR_FUN_HPP #define SPROUT_FUNCTIONAL_PTR_FUN_HPP #include #include namespace sprout { // D.8.2.1 adaptors (deprecated) template class pointer_to_unary_function : public sprout::unary_function { protected: Result (*ptr_)(Arg); public: pointer_to_unary_function() = default; explicit SPROUT_CONSTEXPR pointer_to_unary_function(Result (*x)(Arg)) : ptr_(x) {} SPROUT_CONSTEXPR Result operator()(Arg x) const { return ptr_(x); } }; template inline SPROUT_CONSTEXPR sprout::pointer_to_unary_function ptr_fun(Result (*x)(Arg)) { return sprout::pointer_to_unary_function(x); } template class pointer_to_binary_function : public sprout::binary_function { protected: Result (*ptr_)(Arg1, Arg2); public: pointer_to_binary_function() = default; explicit SPROUT_CONSTEXPR pointer_to_binary_function(Result (*x)(Arg1, Arg2)) : ptr_(x) {} SPROUT_CONSTEXPR Result operator()(Arg1 x, Arg2 y) const { return ptr_(x, y); } }; template inline SPROUT_CONSTEXPR sprout::pointer_to_binary_function ptr_fun(Result (*x)(Arg1, Arg2)) { return sprout::pointer_to_binary_function(x); } } // namespace sprout #endif // #ifndef SPROUT_FUNCTIONAL_PTR_FUN_HPP