diff --git a/include/boost/iterator/transform_iterator.hpp b/include/boost/iterator/transform_iterator.hpp index 1a229e2..c365fe0 100644 --- a/include/boost/iterator/transform_iterator.hpp +++ b/include/boost/iterator/transform_iterator.hpp @@ -20,8 +20,6 @@ #include #include #include -#include - #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) # include @@ -37,18 +35,33 @@ namespace boost namespace detail { + + template + struct function_object_result + { + typedef typename UnaryFunc::result_type type; + }; + +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + template + struct function_object_result + { + typedef Return type; + }; +#endif + // Compute the iterator_adaptor instantiation to be used for transform_iterator template struct transform_iterator_base { private: - typedef typename std::iterator_traits::reference Arg1; - // By default, dereferencing the iterator yields the same as - // the function. + // the function. Do we need to adjust the way + // function_object_result is computed for the standard + // proposal (e.g. using Doug's result_of)? typedef typename ia_dflt_help< Reference - , result_of::value_type)> + , function_object_result >::type reference; // To get the default for Value: remove any reference on the @@ -100,7 +113,7 @@ namespace boost #endif } - template < + template< class OtherUnaryFunction , class OtherIterator , class OtherReference diff --git a/test/transform_iterator_test.cpp b/test/transform_iterator_test.cpp index e72fc79..bf08dd2 100644 --- a/test/transform_iterator_test.cpp +++ b/test/transform_iterator_test.cpp @@ -102,16 +102,6 @@ int mult_2(int arg) return arg*2; } -struct polymorphic_mult_functor -{ - //Implement result_of protocol - template struct result; - template struct result {typedef T type;}; - - template - typename result::type - operator()(const T& _arg) const {return _arg*2;} -}; int main() @@ -254,25 +244,5 @@ main() ); } - // Test transform_iterator with polymorphic object function - { - int x[N], y[N]; - for (int k = 0; k < N; ++k) - x[k] = k; - std::copy(x, x + N, y); - - for (int k2 = 0; k2 < N; ++k2) - x[k2] = x[k2] * 2; - - boost::input_iterator_test( - boost::make_transform_iterator(y, polymorphic_mult_functor()), x[0], x[1]); - - boost::input_iterator_test( - boost::make_transform_iterator(&y[0], polymorphic_mult_functor()), x[0], x[1]); - - boost::random_access_readable_iterator_test( - boost::make_transform_iterator(y, polymorphic_mult_functor()), N, x); - } - return boost::report_errors(); }