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 + +#ifndef BOOST_FOREACH_USE_RVALUE_REFERENCE_BINDING +# 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/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 + +#ifndef BOOST_FOREACH_USE_RVALUE_REFERENCE_BINDING +# 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/Jamfile.v2 =================================================================== --- libs/foreach/test/Jamfile.v2 (revision 70472) +++ libs/foreach/test/Jamfile.v2 (working copy) @@ -32,5 +32,9 @@ [ run rvalue_nonconst_r.cpp ] [ run dependent_type.cpp ] [ run misc.cpp ] + [ run noncopyable_rvalue_const.cpp ] + [ run noncopyable_rvalue_nonconst.cpp ] + [ run noncopyable_rvalue_const_r.cpp ] + [ run noncopyable_rvalue_nonconst_r.cpp ] [ compile noncopyable.cpp ] ; 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 + +#ifndef BOOST_FOREACH_USE_RVALUE_REFERENCE_BINDING +# 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/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 + +#ifndef BOOST_FOREACH_USE_RVALUE_REFERENCE_BINDING +# 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