diff --git a/doc/index.rst b/doc/index.rst index 497d9af..924cfc8 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -115,8 +115,8 @@ __ iterator_facade.pdf __ iterator_adaptor.pdf Both |facade| and |adaptor| as well as many of the `specialized -adaptors`_ mentioned below have been proposed for standardization, -and accepted into the first C++ technical report; see our +adaptors`_ mentioned below have been proposed for standardization; +see our `Standard Proposal For Iterator Facade and Adaptor`__ (PDF__) diff --git a/include/boost/iterator/function_input_iterator.hpp b/include/boost/iterator/function_input_iterator.hpp index 8a793df..f3e9de9 100644 --- a/include/boost/iterator/function_input_iterator.hpp +++ b/include/boost/iterator/function_input_iterator.hpp @@ -9,6 +9,7 @@ #ifndef BOOST_FUNCTION_INPUT_ITERATOR #define BOOST_FUNCTION_INPUT_ITERATOR +#include #include #include #include @@ -17,6 +18,7 @@ #include #include #include +#include namespace boost { @@ -28,9 +30,9 @@ namespace iterators { class function_input_iterator : public iterator_facade< function_input_iterator, - typename Function::result_type, + BOOST_DEDUCED_TYPENAME result_of::type, single_pass_traversal_tag, - typename Function::result_type const & + BOOST_DEDUCED_TYPENAME result_of::type const & > { public: @@ -46,7 +48,7 @@ namespace iterators { ++state; } - typename Function::result_type const & + BOOST_DEDUCED_TYPENAME result_of::type const & dereference() const { return (value ? value : value = (*f)()).get(); } @@ -58,7 +60,7 @@ namespace iterators { private: Function * f; Input state; - mutable optional value; + mutable optional::type> value; }; template diff --git a/test/function_input_iterator_test.cpp b/test/function_input_iterator_test.cpp index b08caa6..fa8f12b 100644 --- a/test/function_input_iterator_test.cpp +++ b/test/function_input_iterator_test.cpp @@ -11,6 +11,7 @@ #include #include +#include #include namespace { @@ -96,6 +97,23 @@ int main(int argc, char * argv[]) assert(generated[i] == 42 + i); cout << "function iterator test with stateful function object successful." << endl; +#if !defined(BOOST_NO_CXX11_LAMBDAS) && !defined(BOOST_NO_CXX11_AUTO_DECLARATIONS) + // test the iterator with lambda expressions + int num = 42; + auto lambda_generator = [&num] { return num++; }; + vector().swap(generated); + copy( + boost::make_function_input_iterator(lambda_generator, 0), + boost::make_function_input_iterator(lambda_generator, 10), + back_inserter(generated) + ); + + assert(generated.size() == 10); + for(std::size_t i = 0; i != 10; ++i) + assert(generated[i] == 42 + i); + cout << "function iterator test with lambda expressions successful." << endl; +#endif // BOOST_NO_CXX11_LAMBDAS + return 0; } diff --git a/test/iterator_adaptor_test.cpp b/test/iterator_adaptor_test.cpp index 5b5e0c3..66c67b4 100644 --- a/test/iterator_adaptor_test.cpp +++ b/test/iterator_adaptor_test.cpp @@ -33,37 +33,6 @@ using boost::dummyT; -struct mult_functor { - typedef int result_type; - typedef int argument_type; - // Functors used with transform_iterator must be - // DefaultConstructible, as the transform_iterator must be - // DefaultConstructible to satisfy the requirements for - // TrivialIterator. - mult_functor() { } - mult_functor(int aa) : a(aa) { } - int operator()(int b) const { return a * b; } - int a; -}; - -template -struct select1st_ - : public std::unary_function -{ - const typename Pair::first_type& operator()(const Pair& x) const { - return x.first; - } - typename Pair::first_type& operator()(Pair& x) const { - return x.first; - } -}; - -struct one_or_four { - bool operator()(dummyT x) const { - return x.foo() == 1 || x.foo() == 4; - } -}; - typedef std::deque storage; typedef std::deque pointer_deque; typedef std::set iterator_set; diff --git a/test/pointee.cpp b/test/pointee.cpp index 71d1d04..3b99947 100644 --- a/test/pointee.cpp +++ b/test/pointee.cpp @@ -56,12 +56,24 @@ int main() STATIC_ASSERT_SAME(boost::pointee::type, X); STATIC_ASSERT_SAME(boost::pointee::type, X const); +#if defined(BOOST_NO_CXX11_SMART_PTR) + STATIC_ASSERT_SAME(boost::pointee >::type, int); STATIC_ASSERT_SAME(boost::pointee >::type, X); STATIC_ASSERT_SAME(boost::pointee >::type, int const); STATIC_ASSERT_SAME(boost::pointee >::type, X const); +#else + + STATIC_ASSERT_SAME(boost::pointee >::type, int); + STATIC_ASSERT_SAME(boost::pointee >::type, X); + + STATIC_ASSERT_SAME(boost::pointee >::type, int const); + STATIC_ASSERT_SAME(boost::pointee >::type, X const); + +#endif + STATIC_ASSERT_SAME(boost::pointee::iterator >::type, int); STATIC_ASSERT_SAME(boost::pointee::iterator >::type, X);