annotate DEPENDENCIES/generic/include/boost/range/detail/default_constructible_unary_fn.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents f46d142149f5
children
rev   line source
Chris@102 1 // Boost.Range library
Chris@102 2 //
Chris@102 3 // Copyright Neil Groves 2014. Use, modification and
Chris@102 4 // distribution is subject to the Boost Software License, Version
Chris@102 5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@102 6 // http://www.boost.org/LICENSE_1_0.txt)
Chris@102 7 //
Chris@102 8 // For more information, see http://www.boost.org/libs/range/
Chris@102 9 //
Chris@102 10 #ifndef BOOST_RANGE_DETAIL_DEFAULT_CONSTRUCTIBLE_UNARY_FN_HPP_INCLUDED
Chris@102 11 #define BOOST_RANGE_DETAIL_DEFAULT_CONSTRUCTIBLE_UNARY_FN_HPP_INCLUDED
Chris@102 12
Chris@102 13 #include <boost/optional/optional.hpp>
Chris@102 14 #include <boost/mpl/if.hpp>
Chris@102 15 #include <boost/type_traits/has_trivial_constructor.hpp>
Chris@102 16
Chris@102 17 namespace boost
Chris@102 18 {
Chris@102 19 namespace range_detail
Chris@102 20 {
Chris@102 21
Chris@102 22 template<typename F, typename R>
Chris@102 23 class default_constructible_unary_fn_wrapper
Chris@102 24 {
Chris@102 25 public:
Chris@102 26 typedef R result_type;
Chris@102 27
Chris@102 28 default_constructible_unary_fn_wrapper()
Chris@102 29 {
Chris@102 30 }
Chris@102 31 default_constructible_unary_fn_wrapper(const F& source)
Chris@102 32 : m_impl(source)
Chris@102 33 {
Chris@102 34 }
Chris@102 35 template<typename Arg>
Chris@102 36 R operator()(const Arg& arg) const
Chris@102 37 {
Chris@102 38 BOOST_ASSERT(m_impl);
Chris@102 39 return (*m_impl)(arg);
Chris@102 40 }
Chris@102 41 template<typename Arg>
Chris@102 42 R operator()(Arg& arg) const
Chris@102 43 {
Chris@102 44 BOOST_ASSERT(m_impl);
Chris@102 45 return (*m_impl)(arg);
Chris@102 46 }
Chris@102 47 private:
Chris@102 48 boost::optional<F> m_impl;
Chris@102 49 };
Chris@102 50
Chris@102 51 template<typename F, typename R>
Chris@102 52 struct default_constructible_unary_fn_gen
Chris@102 53 {
Chris@102 54 typedef typename boost::mpl::if_<
Chris@102 55 boost::has_trivial_default_constructor<F>,
Chris@102 56 F,
Chris@102 57 default_constructible_unary_fn_wrapper<F,R>
Chris@102 58 >::type type;
Chris@102 59 };
Chris@102 60
Chris@102 61 } // namespace range_detail
Chris@102 62 } // namespace boost
Chris@102 63
Chris@102 64 #endif // include guard