diff options
Diffstat (limited to 'src/third_party/boost-1.60.0/boost/range/detail/default_constructible_unary_fn.hpp')
-rw-r--r-- | src/third_party/boost-1.60.0/boost/range/detail/default_constructible_unary_fn.hpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/third_party/boost-1.60.0/boost/range/detail/default_constructible_unary_fn.hpp b/src/third_party/boost-1.60.0/boost/range/detail/default_constructible_unary_fn.hpp new file mode 100644 index 00000000000..374ddda15d4 --- /dev/null +++ b/src/third_party/boost-1.60.0/boost/range/detail/default_constructible_unary_fn.hpp @@ -0,0 +1,64 @@ +// Boost.Range library +// +// Copyright Neil Groves 2014. Use, modification and +// distribution is subject to 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) +// +// For more information, see http://www.boost.org/libs/range/ +// +#ifndef BOOST_RANGE_DETAIL_DEFAULT_CONSTRUCTIBLE_UNARY_FN_HPP_INCLUDED +#define BOOST_RANGE_DETAIL_DEFAULT_CONSTRUCTIBLE_UNARY_FN_HPP_INCLUDED + +#include <boost/optional/optional.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/has_trivial_constructor.hpp> + +namespace boost +{ + namespace range_detail + { + +template<typename F, typename R> +class default_constructible_unary_fn_wrapper +{ +public: + typedef R result_type; + + default_constructible_unary_fn_wrapper() + { + } + default_constructible_unary_fn_wrapper(const F& source) + : m_impl(source) + { + } + template<typename Arg> + R operator()(const Arg& arg) const + { + BOOST_ASSERT(m_impl); + return (*m_impl)(arg); + } + template<typename Arg> + R operator()(Arg& arg) const + { + BOOST_ASSERT(m_impl); + return (*m_impl)(arg); + } +private: + boost::optional<F> m_impl; +}; + +template<typename F, typename R> +struct default_constructible_unary_fn_gen +{ + typedef typename boost::mpl::if_< + boost::has_trivial_default_constructor<F>, + F, + default_constructible_unary_fn_wrapper<F,R> + >::type type; +}; + + } // namespace range_detail +} // namespace boost + +#endif // include guard |