Index: libs/foreach/test/cxx11_lambda.cpp =================================================================== --- libs/foreach/test/cxx11_lambda.cpp (revision 0) +++ libs/foreach/test/cxx11_lambda.cpp (revision 0) @@ -0,0 +1,40 @@ +// (C) Copyright Eric Niebler 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 25 August 2005 : Initial version. +*/ + +#include +#include +#include +#include + +#ifdef BOOST_NO_LAMBDAS +int test_main( int, char*[] ) +{ + return 0; +} +#else + +/////////////////////////////////////////////////////////////////////////////// +// test_main +// +int test_main( int, char*[] ) +{ + int counter = 0; + + BOOST_FOREACH(int i, [](){ return std::vector(4, 4); }()) + { + counter += i; + } + + BOOST_CHECK(16 == counter); + + return 0; +} + +#endif Index: libs/foreach/test/pair_byval_r.cpp =================================================================== --- libs/foreach/test/pair_byval_r.cpp (revision 75397) +++ libs/foreach/test/pair_byval_r.cpp (working copy) @@ -33,9 +33,10 @@ // int test_main( int, char*[] ) { +#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) boost::mpl::true_ *p = BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(my_pair); (void)p; - +#endif // non-const containers by value BOOST_CHECK(sequence_equal_byval_n_r(my_pair, "\5\4\3\2\1")); Index: libs/foreach/test/array_byval.cpp =================================================================== --- libs/foreach/test/array_byval.cpp (revision 75397) +++ libs/foreach/test/array_byval.cpp (working copy) @@ -32,8 +32,10 @@ // int test_main( int, char*[] ) { +#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) boost::mpl::false_ *p = BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(my_array); (void)p; +#endif // non-const containers by value BOOST_CHECK(sequence_equal_byval_n(my_array, "\1\2\3\4\5")); Index: libs/foreach/test/stl_byval_r.cpp =================================================================== --- libs/foreach/test/stl_byval_r.cpp (revision 75397) +++ libs/foreach/test/stl_byval_r.cpp (working copy) @@ -48,9 +48,10 @@ // int test_main( int, char*[] ) { +#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) boost::mpl::false_ *p = BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(my_list); (void)p; - +#endif // non-const containers by value BOOST_CHECK(sequence_equal_byval_n_r(my_list, "\5\4\3\2\1")); Index: libs/foreach/test/pair_byval.cpp =================================================================== --- libs/foreach/test/pair_byval.cpp (revision 75397) +++ libs/foreach/test/pair_byval.cpp (working copy) @@ -33,9 +33,10 @@ // int test_main( int, char*[] ) { +#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) boost::mpl::true_ *p = BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(my_pair); (void)p; - +#endif // non-const containers by value BOOST_CHECK(sequence_equal_byval_n(my_pair, "\1\2\3\4\5")); Index: libs/foreach/test/cstr_byval_r.cpp =================================================================== --- libs/foreach/test/cstr_byval_r.cpp (revision 75397) +++ libs/foreach/test/cstr_byval_r.cpp (working copy) @@ -33,9 +33,10 @@ // int test_main( int, char*[] ) { +#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) boost::mpl::true_ *p = BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(my_ntcs); (void)p; - +#endif // non-const containers by value BOOST_CHECK(sequence_equal_byval_n_r(my_ntcs, "\5\4\3\2\1")); Index: libs/foreach/test/noncopyable_rvalue_nonconst_r.cpp =================================================================== --- libs/foreach/test/noncopyable_rvalue_nonconst_r.cpp (revision 0) +++ libs/foreach/test/noncopyable_rvalue_nonconst_r.cpp (revision 0) @@ -0,0 +1,68 @@ +// (C) Copyright Eric Niebler 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 25 August 2005 : Initial version. +*/ + +#include +#include + +#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) +# error Expected failure : non-copyable rvalues disallowed +#else + +class my_container +{ +public: + my_container() + { + array_[0] = 1; + array_[1] = 2; + array_[2] = 3; + array_[3] = 4; + array_[4] = 5; + } + + typedef int* iterator; + typedef int const* const_iterator; + + iterator begin() { return array_; } + const_iterator begin() const { return array_; } + + iterator end() { return array_ + 5; } + const_iterator end() const { return array_ + 5; } + +private: + int array_[5]; + + // non-copyable + my_container(my_container const &); + my_container &operator =(my_container const &); + + // non-movable + my_container(my_container &&); + my_container &operator =(my_container &&); +}; + +/////////////////////////////////////////////////////////////////////////////// +// test_main +// +int test_main( int, char*[] ) +{ + int counter = 0; + + BOOST_REVERSE_FOREACH(int i, my_container()) + { + counter += i; + } + + BOOST_CHECK(15 == counter); + + return 0; +} + +#endif Index: libs/foreach/test/rvalue_nonconst_access_fail.cpp =================================================================== --- libs/foreach/test/rvalue_nonconst_access_fail.cpp (revision 0) +++ libs/foreach/test/rvalue_nonconst_access_fail.cpp (revision 0) @@ -0,0 +1,32 @@ +// (C) Copyright Eric Niebler 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 25 August 2005 : Initial version. +*/ + +#include +#include +#include + +#ifdef BOOST_FOREACH_NO_RVALUE_DETECTION +# error Expected failure : rvalues disallowed +#else + +/////////////////////////////////////////////////////////////////////////////// +// test_main +// +int test_main( int, char*[] ) +{ + BOOST_FOREACH(int &i, std::vector(4, 4)) + { + (void)i; + } + + return 0; +} + +#endif Index: libs/foreach/test/stl_byval.cpp =================================================================== --- libs/foreach/test/stl_byval.cpp (revision 75397) +++ libs/foreach/test/stl_byval.cpp (working copy) @@ -48,9 +48,10 @@ // int test_main( int, char*[] ) { +#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) boost::mpl::false_ *p = BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(my_list); (void)p; - +#endif // non-const containers by value BOOST_CHECK(sequence_equal_byval_n(my_list, "\1\2\3\4\5")); Index: libs/foreach/test/char_array_fail.cpp =================================================================== --- libs/foreach/test/char_array_fail.cpp (revision 0) +++ libs/foreach/test/char_array_fail.cpp (revision 0) @@ -0,0 +1,27 @@ +// noncopyable.cpp +/// +// (C) Copyright Eric Niebler 2004. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 21 December 2005 : Initial version. +*/ + +#include + +/////////////////////////////////////////////////////////////////////////////// +// main +// +int main( int, char*[] ) +{ + char ar[] = "\1\2\3\4\5"; + BOOST_FOREACH( char ch, ar ) + { + (void)ch; + } + + return 0; +} Index: libs/foreach/test/cstr_byval.cpp =================================================================== --- libs/foreach/test/cstr_byval.cpp (revision 75397) +++ libs/foreach/test/cstr_byval.cpp (working copy) @@ -33,9 +33,10 @@ // int test_main( int, char*[] ) { +#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) boost::mpl::true_ *p = BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(my_ntcs); (void)p; - +#endif // non-const containers by value BOOST_CHECK(sequence_equal_byval_n(my_ntcs, "\1\2\3\4\5")); Index: libs/foreach/test/noncopyable_rvalue_nonconst.cpp =================================================================== --- libs/foreach/test/noncopyable_rvalue_nonconst.cpp (revision 0) +++ libs/foreach/test/noncopyable_rvalue_nonconst.cpp (revision 0) @@ -0,0 +1,68 @@ +// (C) Copyright Eric Niebler 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 25 August 2005 : Initial version. +*/ + +#include +#include + +#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) +# error Expected failure : non-copyable rvalues disallowed +#else + +class my_container +{ +public: + my_container() + { + array_[0] = 1; + array_[1] = 2; + array_[2] = 3; + array_[3] = 4; + array_[4] = 5; + } + + typedef int* iterator; + typedef int const* const_iterator; + + iterator begin() { return array_; } + const_iterator begin() const { return array_; } + + iterator end() { return array_ + 5; } + const_iterator end() const { return array_ + 5; } + +private: + int array_[5]; + + // non-copyable + my_container(my_container const &); + my_container &operator =(my_container const &); + + // non-movable + my_container(my_container &&); + my_container &operator =(my_container &&); +}; + +/////////////////////////////////////////////////////////////////////////////// +// test_main +// +int test_main( int, char*[] ) +{ + int counter = 0; + + BOOST_FOREACH(int i, my_container()) + { + counter += i; + } + + BOOST_CHECK(15 == counter); + + return 0; +} + +#endif Index: libs/foreach/test/rvalue_nonconst_access_r_fail.cpp =================================================================== --- libs/foreach/test/rvalue_nonconst_access_r_fail.cpp (revision 0) +++ libs/foreach/test/rvalue_nonconst_access_r_fail.cpp (revision 0) @@ -0,0 +1,32 @@ +// (C) Copyright Eric Niebler 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 25 August 2005 : Initial version. +*/ + +#include +#include +#include + +#ifdef BOOST_FOREACH_NO_RVALUE_DETECTION +# error Expected failure : rvalues disallowed +#else + +/////////////////////////////////////////////////////////////////////////////// +// test_main +// +int test_main( int, char*[] ) +{ + BOOST_REVERSE_FOREACH(int &i, std::vector(4, 4)) + { + (void)i; + } + + return 0; +} + +#endif Index: libs/foreach/test/Jamfile.v2 =================================================================== --- libs/foreach/test/Jamfile.v2 (revision 75397) +++ libs/foreach/test/Jamfile.v2 (working copy) @@ -33,4 +33,16 @@ [ run dependent_type.cpp ] [ run misc.cpp ] [ compile noncopyable.cpp ] + [ run noncopyable_rvalue_const.cpp ] + [ run noncopyable_rvalue_nonconst.cpp ] + [ run noncopyable_rvalue_const_r.cpp ] + [ run noncopyable_rvalue_nonconst_r.cpp ] + [ run cxx11_gcc_workaround.cpp ] + [ run cxx11_gcc_workaround_r.cpp ] + [ run cxx11_lambda.cpp ] + [ run cxx11_lambda_r.cpp ] + [ compile-fail char_array_fail.cpp ] + [ compile-fail char_array_r_fail.cpp ] + [ compile-fail rvalue_nonconst_access_fail.cpp ] + [ compile-fail rvalue_nonconst_access_r_fail.cpp ] ; Index: libs/foreach/test/cxx11_gcc_workaround_r.cpp =================================================================== --- libs/foreach/test/cxx11_gcc_workaround_r.cpp (revision 0) +++ libs/foreach/test/cxx11_gcc_workaround_r.cpp (revision 0) @@ -0,0 +1,52 @@ +// (C) Copyright Eric Niebler 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 25 August 2005 : Initial version. +*/ + +#include +#include +#include +#include + +#ifdef BOOST_NO_RVALUE_REFERENCES +int test_main( int, char*[] ) +{ + return 0; +} +#else + +template +T const add_const_if_rvalue(T&& t) +{ + return t; +} + +template +void f() +{ + int counter = 0; + + BOOST_FOREACH(int i, add_const_if_rvalue(std::vector(4, 4))) + { + counter += i; + } + + BOOST_CHECK(16 == counter); +} + +/////////////////////////////////////////////////////////////////////////////// +// test_main +// +int test_main( int, char*[] ) +{ + f(); + + return 0; +} + +#endif Index: libs/foreach/test/noncopyable_rvalue_const_r.cpp =================================================================== --- libs/foreach/test/noncopyable_rvalue_const_r.cpp (revision 0) +++ libs/foreach/test/noncopyable_rvalue_const_r.cpp (revision 0) @@ -0,0 +1,70 @@ +// (C) Copyright Eric Niebler 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 25 August 2005 : Initial version. +*/ + +#include +#include + +#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) +# error Expected failure : non-copyable rvalues disallowed +#else + +class my_container +{ +public: + my_container() + { + array_[0] = 1; + array_[1] = 2; + array_[2] = 3; + array_[3] = 4; + array_[4] = 5; + } + + typedef int* iterator; + typedef int const* const_iterator; + + iterator begin() { return array_; } + const_iterator begin() const { return array_; } + + iterator end() { return array_ + 5; } + const_iterator end() const { return array_ + 5; } + +private: + int array_[5]; + + // non-copyable + my_container(my_container const &); + my_container &operator =(my_container const &); + + // non-movable + my_container(my_container &&); + my_container &operator =(my_container &&); +}; + +typedef my_container const const_my_container; + +/////////////////////////////////////////////////////////////////////////////// +// test_main +// +int test_main( int, char*[] ) +{ + int counter = 0; + + BOOST_REVERSE_FOREACH(int i, const_my_container()) + { + counter += i; + } + + BOOST_CHECK(15 == counter); + + return 0; +} + +#endif Index: libs/foreach/test/cxx11_lambda_r.cpp =================================================================== --- libs/foreach/test/cxx11_lambda_r.cpp (revision 0) +++ libs/foreach/test/cxx11_lambda_r.cpp (revision 0) @@ -0,0 +1,40 @@ +// (C) Copyright Eric Niebler 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 25 August 2005 : Initial version. +*/ + +#include +#include +#include +#include + +#ifdef BOOST_NO_LAMBDAS +int test_main( int, char*[] ) +{ + return 0; +} +#else + +/////////////////////////////////////////////////////////////////////////////// +// test_main +// +int test_main( int, char*[] ) +{ + int counter = 0; + + BOOST_REVERSE_FOREACH(int i, [](){ return std::vector(4, 4); }()) + { + counter += i; + } + + BOOST_CHECK(16 == counter); + + return 0; +} + +#endif Index: libs/foreach/test/char_array_r_fail.cpp =================================================================== --- libs/foreach/test/char_array_r_fail.cpp (revision 0) +++ libs/foreach/test/char_array_r_fail.cpp (revision 0) @@ -0,0 +1,27 @@ +// noncopyable.cpp +/// +// (C) Copyright Eric Niebler 2004. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 21 December 2005 : Initial version. +*/ + +#include + +/////////////////////////////////////////////////////////////////////////////// +// main +// +int main( int, char*[] ) +{ + char ar[] = "\1\2\3\4\5"; + BOOST_REVERSE_FOREACH( char ch, ar ) + { + (void)ch; + } + + return 0; +} Index: libs/foreach/test/cxx11_gcc_workaround.cpp =================================================================== --- libs/foreach/test/cxx11_gcc_workaround.cpp (revision 0) +++ libs/foreach/test/cxx11_gcc_workaround.cpp (revision 0) @@ -0,0 +1,52 @@ +// (C) Copyright Eric Niebler 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 25 August 2005 : Initial version. +*/ + +#include +#include +#include +#include + +#ifdef BOOST_NO_RVALUE_REFERENCES +int test_main( int, char*[] ) +{ + return 0; +} +#else + +template +T const add_const_if_rvalue(T&& t) +{ + return t; +} + +template +void f() +{ + int counter = 0; + + BOOST_FOREACH(int i, add_const_if_rvalue(std::vector(4, 4))) + { + counter += i; + } + + BOOST_CHECK(16 == counter); +} + +/////////////////////////////////////////////////////////////////////////////// +// test_main +// +int test_main( int, char*[] ) +{ + f(); + + return 0; +} + +#endif Index: libs/foreach/test/array_byval_r.cpp =================================================================== --- libs/foreach/test/array_byval_r.cpp (revision 75397) +++ libs/foreach/test/array_byval_r.cpp (working copy) @@ -32,9 +32,10 @@ // int test_main( int, char*[] ) { +#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) boost::mpl::false_ *p = BOOST_FOREACH_IS_LIGHTWEIGHT_PROXY(my_array); (void)p; - +#endif // non-const containers by value BOOST_CHECK(sequence_equal_byval_n_r(my_array, "\5\4\3\2\1")); Index: libs/foreach/test/noncopyable_rvalue_const.cpp =================================================================== --- libs/foreach/test/noncopyable_rvalue_const.cpp (revision 0) +++ libs/foreach/test/noncopyable_rvalue_const.cpp (revision 0) @@ -0,0 +1,70 @@ +// (C) Copyright Eric Niebler 2005. +// Use, modification and distribution are subject to the +// Boost Software License, Version 1.0. (See accompanying file +// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +/* + Revision history: + 25 August 2005 : Initial version. +*/ + +#include +#include + +#if !defined(BOOST_FOREACH_USE_CXX11) && !defined(BOOST_FOREACH_USE_CXX11_GCC_WORKAROUND) +# error Expected failure : non-copyable rvalues disallowed +#else + +class my_container +{ +public: + my_container() + { + array_[0] = 1; + array_[1] = 2; + array_[2] = 3; + array_[3] = 4; + array_[4] = 5; + } + + typedef int* iterator; + typedef int const* const_iterator; + + iterator begin() { return array_; } + const_iterator begin() const { return array_; } + + iterator end() { return array_ + 5; } + const_iterator end() const { return array_ + 5; } + +private: + int array_[5]; + + // non-copyable + my_container(my_container const &); + my_container &operator =(my_container const &); + + // non-movable + my_container(my_container &&); + my_container &operator =(my_container &&); +}; + +typedef my_container const const_my_container; + +/////////////////////////////////////////////////////////////////////////////// +// test_main +// +int test_main( int, char*[] ) +{ + int counter = 0; + + BOOST_FOREACH(int i, const_my_container()) + { + counter += i; + } + + BOOST_CHECK(15 == counter); + + return 0; +} + +#endif