diff --git a/include/boost/iterator/function_input_iterator.hpp b/include/boost/iterator/function_input_iterator.hpp index a82b0c0..caa6272 100644 --- a/include/boost/iterator/function_input_iterator.hpp +++ b/include/boost/iterator/function_input_iterator.hpp @@ -20,19 +20,38 @@ #include #include +#ifdef BOOST_RESULT_OF_USE_TR1 +#include +#endif + namespace boost { namespace iterators { namespace impl { + // Computes the return type of an lvalue-call with an empty argument, + // i.e. decltype(declval()()). F should be a nullary lvalue-callable + // or function. + template + struct result_of_nullary_lvalue_call + { + typedef typename result_of< +#ifdef BOOST_RESULT_OF_USE_TR1 + typename mpl::if_, F&, F>::type() +#else + F&() +#endif + >::type type; + }; + template class function_input_iterator : public iterator_facade< function_input_iterator, - typename result_of::type, + typename result_of_nullary_lvalue_call::type, single_pass_traversal_tag, - typename result_of::type const & + typename result_of_nullary_lvalue_call::type const & > { public: @@ -48,7 +67,7 @@ namespace iterators { ++state; } - typename result_of::type const & + typename result_of_nullary_lvalue_call::type const & dereference() const { return (value ? value : value = (*f)()).get(); } @@ -60,7 +79,7 @@ namespace iterators { private: Function * f; Input state; - mutable optional::type> value; + mutable optional::type> value; }; template