From c09c8ca2b27de4f493c1569f6a5f968263c96642 Mon Sep 17 00:00:00 2001 From: nekko1119 Date: Mon, 28 Dec 2015 02:45:49 +0900 Subject: [PATCH 1/5] Support lambda expressions in function_input_iterator --- .../boost/iterator/function_input_iterator.hpp | 9 +++++---- test/function_input_iterator_test.cpp | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/include/boost/iterator/function_input_iterator.hpp b/include/boost/iterator/function_input_iterator.hpp index 8a793df..1ad91b3 100644 --- a/include/boost/iterator/function_input_iterator.hpp +++ b/include/boost/iterator/function_input_iterator.hpp @@ -17,6 +17,7 @@ #include #include #include +#include namespace boost { @@ -28,9 +29,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 +47,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 +59,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..e57ca2a 100644 --- a/test/function_input_iterator_test.cpp +++ b/test/function_input_iterator_test.cpp @@ -96,6 +96,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; } From 434818cce7ff77c5f16b9e47701afef8bd62cb64 Mon Sep 17 00:00:00 2001 From: Nathan Wilson Date: Wed, 27 Jan 2016 22:22:55 -0600 Subject: [PATCH 2/5] Remove incorrect documentation stating iterator_facade and iterator_adapter had been accepted into the TR1. Fixes #8010 --- doc/index.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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__) From 53e8ac401f506e1e0162e0ae8602587554093846 Mon Sep 17 00:00:00 2001 From: Rene Rivera Date: Fri, 7 Oct 2016 23:07:34 -0500 Subject: [PATCH 3/5] Add, and update, documentation build targets. --- doc/Jamfile.v2 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index ae485f1..66ec0e4 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -20,4 +20,8 @@ boostbook standalone pdf:boost.url.prefix=http://www.boost.org/doc/libs/release/libs/iterator/doc ; - +############################################################################### +alias boostdoc ; +explicit boostdoc ; +alias boostrelease : standalone ; +explicit boostrelease ; From 11e3715f37072c542d26f490dbcd575ee39009d3 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Mon, 7 Nov 2016 14:01:19 -0500 Subject: [PATCH 4/5] Updated to use unique_ptr instead of auto_ptr when appropriate. Removed unnecessary structs. --- test/iterator_adaptor_test.cpp | 31 ------------------------------- test/pointee.cpp | 12 ++++++++++++ 2 files changed, 12 insertions(+), 31 deletions(-) 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); From 89d3ec7662978b579500064a5a61c0ab9016ba41 Mon Sep 17 00:00:00 2001 From: Edward Diener Date: Sat, 17 Dec 2016 19:32:52 -0500 Subject: [PATCH 5/5] Add inclusion of config.hpp --- include/boost/iterator/function_input_iterator.hpp | 1 + test/function_input_iterator_test.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/include/boost/iterator/function_input_iterator.hpp b/include/boost/iterator/function_input_iterator.hpp index 1ad91b3..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 diff --git a/test/function_input_iterator_test.cpp b/test/function_input_iterator_test.cpp index e57ca2a..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 {