From 4ebbbba82b62e6f7deaefe1ad22a26a894ff3417 Mon Sep 17 00:00:00 2001 From: Neil Groves Date: Sun, 9 Mar 2014 00:28:43 +0000 Subject: [PATCH] ticket 7885 rvalue support for metafunctions. --- include/boost/range/const_iterator.hpp | 2 +- .../boost/range/const_reverse_iterator.hpp | 3 +- include/boost/range/difference_type.hpp | 8 ++- include/boost/range/has_range_iterator.hpp | 7 ++- include/boost/range/mutable_iterator.hpp | 6 +- include/boost/range/pointer.hpp | 3 +- include/boost/range/reverse_iterator.hpp | 4 +- test/Jamfile.v2 | 13 ++++ test/category.cpp | 61 ++++++++++++++++++ test/const_iterator.cpp | 61 ++++++++++++++++++ test/const_reverse_iterator.cpp | 62 +++++++++++++++++++ test/difference_type.cpp | 61 ++++++++++++++++++ test/has_range_iterator.cpp | 11 ++++ test/iterator.cpp | 61 ++++++++++++++++++ test/mutable_iterator.cpp | 61 ++++++++++++++++++ test/pointer.cpp | 61 ++++++++++++++++++ test/reference.cpp | 61 ++++++++++++++++++ test/result_iterator.cpp | 61 ++++++++++++++++++ test/reverse_iterator.cpp | 61 ++++++++++++++++++ test/reverse_result_iterator.cpp | 62 +++++++++++++++++++ test/size_type.cpp | 61 ++++++++++++++++++ test/value_type.cpp | 61 ++++++++++++++++++ 22 files changed, 844 insertions(+), 8 deletions(-) create mode 100644 test/category.cpp create mode 100644 test/const_iterator.cpp create mode 100644 test/const_reverse_iterator.cpp create mode 100644 test/difference_type.cpp create mode 100644 test/iterator.cpp create mode 100644 test/mutable_iterator.cpp create mode 100644 test/pointer.cpp create mode 100644 test/reference.cpp create mode 100644 test/result_iterator.cpp create mode 100644 test/reverse_iterator.cpp create mode 100644 test/reverse_result_iterator.cpp create mode 100644 test/size_type.cpp create mode 100644 test/value_type.cpp diff --git a/include/boost/range/const_iterator.hpp b/include/boost/range/const_iterator.hpp index 1cdbf03..1876794 100644 --- a/include/boost/range/const_iterator.hpp +++ b/include/boost/range/const_iterator.hpp @@ -65,7 +65,7 @@ struct range_const_iterator< T[sz] > template struct range_const_iterator : range_detail::range_const_iterator< - typename remove_reference::type + BOOST_DEDUCED_TYPENAME remove_reference::type > { }; diff --git a/include/boost/range/const_reverse_iterator.hpp b/include/boost/range/const_reverse_iterator.hpp index d580aee..bfe1615 100644 --- a/include/boost/range/const_reverse_iterator.hpp +++ b/include/boost/range/const_reverse_iterator.hpp @@ -26,7 +26,8 @@ namespace boost template< typename C > struct range_const_reverse_iterator - : range_reverse_iterator::type> + : range_reverse_iterator< + const BOOST_DEDUCED_TYPENAME remove_reference::type> { }; } // namespace boost diff --git a/include/boost/range/difference_type.hpp b/include/boost/range/difference_type.hpp index 4578002..afd8b07 100644 --- a/include/boost/range/difference_type.hpp +++ b/include/boost/range/difference_type.hpp @@ -18,11 +18,17 @@ #include #include #include +#include namespace boost { template< class T > - struct range_difference : iterator_difference< typename range_iterator::type > + struct range_difference + : iterator_difference< + BOOST_DEDUCED_TYPENAME range_iterator< + BOOST_DEDUCED_TYPENAME remove_reference::type + >::type + > { }; } diff --git a/include/boost/range/has_range_iterator.hpp b/include/boost/range/has_range_iterator.hpp index 3c7b083..26a6452 100644 --- a/include/boost/range/has_range_iterator.hpp +++ b/include/boost/range/has_range_iterator.hpp @@ -17,6 +17,7 @@ #include #include #include +#include #include namespace boost @@ -67,12 +68,14 @@ namespace boost template struct has_range_iterator - : range_detail::has_range_iterator_impl + : range_detail::has_range_iterator_impl< + BOOST_DEDUCED_TYPENAME remove_reference::type> {}; template struct has_range_const_iterator - : range_detail::has_range_const_iterator_impl + : range_detail::has_range_const_iterator_impl< + BOOST_DEDUCED_TYPENAME remove_reference::type> {}; } // namespace boost diff --git a/include/boost/range/mutable_iterator.hpp b/include/boost/range/mutable_iterator.hpp index f1bd1a1..387262f 100644 --- a/include/boost/range/mutable_iterator.hpp +++ b/include/boost/range/mutable_iterator.hpp @@ -19,12 +19,14 @@ #include +#include #include #include #include namespace boost { + ////////////////////////////////////////////////////////////////////////// // default ////////////////////////////////////////////////////////////////////////// @@ -34,7 +36,9 @@ namespace boost } template< typename C > - struct range_mutable_iterator : range_detail::extract_iterator + struct range_mutable_iterator + : range_detail::extract_iterator< + BOOST_DEDUCED_TYPENAME remove_reference::type> {}; ////////////////////////////////////////////////////////////////////////// diff --git a/include/boost/range/pointer.hpp b/include/boost/range/pointer.hpp index c3ed503..b1e8dc5 100644 --- a/include/boost/range/pointer.hpp +++ b/include/boost/range/pointer.hpp @@ -22,7 +22,8 @@ namespace boost { template< class T > - struct range_pointer : iterator_pointer< typename range_iterator::type > + struct range_pointer + : iterator_pointer< BOOST_DEDUCED_TYPENAME range_iterator::type > { }; } diff --git a/include/boost/range/reverse_iterator.hpp b/include/boost/range/reverse_iterator.hpp index 2569b17..a2c492e 100644 --- a/include/boost/range/reverse_iterator.hpp +++ b/include/boost/range/reverse_iterator.hpp @@ -17,6 +17,7 @@ #include #include +#include #include @@ -30,7 +31,8 @@ namespace boost struct range_reverse_iterator { typedef reverse_iterator< - BOOST_DEDUCED_TYPENAME range_iterator::type > type; + BOOST_DEDUCED_TYPENAME range_iterator< + BOOST_DEDUCED_TYPENAME remove_reference::type>::type > type; }; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index c5bf79e..59251f1 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -147,17 +147,22 @@ test-suite range : [ range-test array ] # [ range-test atl : $(VC71_ROOT)/atlmfc/include ] [ range-test begin ] + [ range-test category ] [ range-test combine ] [ range-test compat2 ] [ range-test compat3 ] + [ range-test const_iterator ] [ range-test const_ranges ] + [ range-test const_reverse_iterator ] [ range-test counting_range ] + [ range-test difference_type ] [ range-test end ] [ range-test extension_mechanism ] [ range-test extension_size ] [ range-test has_range_iterator ] [ range-test irange ] [ range-test istream_range ] + [ range-test iterator ] [ range-test iterator_pair ] [ range-test iterator_range ] [ range-test iterator_range_drop ] @@ -165,9 +170,16 @@ test-suite range : [ range-test iterator_range_variant ] # [ range-test mfc : $(VC71_ROOT)/atlmfc/include ] [ range-test join ] + [ range-test mutable_iterator ] [ range-test partial_workaround ] + [ range-test pointer ] [ range-test pointer_as_iterator ] + [ range-test reference ] + [ range-test result_iterator ] + [ range-test reverse_iterator ] + [ range-test reverse_result_iterator ] [ range-test reversible_range ] + [ range-test size_type ] [ range-test std_container ] [ range-test string ] [ range-test sub_range ] @@ -178,5 +190,6 @@ test-suite range : [ range-test ticket_5811_indirected_optional ] [ range-test ticket_6715_iterator_range_equality ] [ range-test ticket_6944 ] + [ range-test value_type ] ; diff --git a/test/category.cpp b/test/category.cpp new file mode 100644 index 0000000..154c411 --- /dev/null +++ b/test/category.cpp @@ -0,0 +1,61 @@ +// Boost.Range library +// +// Copyright Neil Groves 2014. Use, modification and +// distribution is 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#include +#include +#include + +#include +#include + +#include + +namespace boost_range_test +{ + namespace + { + +void test_category() +{ + typedef std::vector cont; + + BOOST_STATIC_ASSERT(( + boost::is_same< + boost::iterator_category::type, + boost::range_category::type + >::value)); + + BOOST_STATIC_ASSERT(( + boost::is_same< + boost::iterator_category::type, + boost::range_category::type + >::value)); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_ASSERT(( + boost::is_same< + boost::iterator_category::type, + boost::range_category::type + >::value)); +#endif +} + + } // anonymous namespace +} // namespace boost_range_test + +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + boost::unit_test::test_suite* test = + BOOST_TEST_SUITE("Boost.Range range_category meta-function"); + + test->add(BOOST_TEST_CASE(&boost_range_test::test_category)); + + return test; +} diff --git a/test/const_iterator.cpp b/test/const_iterator.cpp new file mode 100644 index 0000000..63238c8 --- /dev/null +++ b/test/const_iterator.cpp @@ -0,0 +1,61 @@ +// Boost.Range library +// +// Copyright Neil Groves 2014. Use, modification and +// distribution is 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#include +#include +#include + +#include +#include + +#include + +namespace boost_range_test +{ + namespace + { + +void test_const_iterator() +{ + typedef std::vector cont; + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::const_iterator, + boost::range_const_iterator::type + >::value)); + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::const_iterator, + boost::range_const_iterator::type + >::value)); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::const_iterator, + boost::range_const_iterator::type + >::value)); +#endif +} + + } // anonymous namespace +} // namespace boost_range_test + +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + boost::unit_test::test_suite* test = + BOOST_TEST_SUITE("Boost.Range range_const_iterator meta-function"); + + test->add(BOOST_TEST_CASE(&boost_range_test::test_const_iterator)); + + return test; +} diff --git a/test/const_reverse_iterator.cpp b/test/const_reverse_iterator.cpp new file mode 100644 index 0000000..44726fd --- /dev/null +++ b/test/const_reverse_iterator.cpp @@ -0,0 +1,62 @@ +// Boost.Range library +// +// Copyright Neil Groves 2014. Use, modification and +// distribution is 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#include +#include +#include + +#include +#include + +#include + +namespace boost_range_test +{ + namespace + { + +void test_const_reverse_iterator() +{ + typedef std::vector cont; + + BOOST_STATIC_ASSERT(( + boost::is_same< + boost::reverse_iterator, + boost::range_const_reverse_iterator::type + >::value)); + + BOOST_STATIC_ASSERT(( + boost::is_same< + boost::reverse_iterator, + boost::range_const_reverse_iterator::type + >::value)); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_ASSERT(( + boost::is_same< + boost::reverse_iterator, + boost::range_const_reverse_iterator::type + >::value)); +#endif +} + + } // anonymous namespace +} // namespace boost_range_test + +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + boost::unit_test::test_suite* test = + BOOST_TEST_SUITE( + "Boost.Range range_const_reverse_iterator meta-function"); + + test->add(BOOST_TEST_CASE(&boost_range_test::test_const_reverse_iterator)); + + return test; +} diff --git a/test/difference_type.cpp b/test/difference_type.cpp new file mode 100644 index 0000000..556250a --- /dev/null +++ b/test/difference_type.cpp @@ -0,0 +1,61 @@ +// Boost.Range library +// +// Copyright Neil Groves 2014. Use, modification and +// distribution is 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#include +#include +#include + +#include +#include + +#include + +namespace boost_range_test +{ + namespace + { + +void test_difference() +{ + typedef std::vector cont; + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::difference_type, + boost::range_difference::type + >::value)); + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::difference_type, + boost::range_difference::type + >::value)); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::difference_type, + boost::range_difference::type + >::value)); +#endif +} + + } // anonymous namespace +} // namespace boost_range_test + +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + boost::unit_test::test_suite* test = + BOOST_TEST_SUITE("Boost.Range range_difference meta-function"); + + test->add(BOOST_TEST_CASE(&boost_range_test::test_difference)); + + return test; +} diff --git a/test/has_range_iterator.cpp b/test/has_range_iterator.cpp index eabb630..2efc88b 100644 --- a/test/has_range_iterator.cpp +++ b/test/has_range_iterator.cpp @@ -9,6 +9,7 @@ // For more information, see http://www.boost.org/libs/range/ // #include +#include #include #include @@ -35,12 +36,22 @@ namespace { test_has_range_iterator_impl< std::vector >(true); test_has_range_iterator_impl< MockClassWithoutIterators >(false); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + test_has_range_iterator_impl&&>(true); + test_has_range_iterator_impl(false); +#endif } void test_has_range_const_iterator() { test_has_range_const_iterator_impl< std::vector >(true); test_has_range_const_iterator_impl< MockClassWithoutIterators >(false); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + test_has_range_const_iterator_impl&&>(true); + test_has_range_const_iterator_impl(false); +#endif } } diff --git a/test/iterator.cpp b/test/iterator.cpp new file mode 100644 index 0000000..76c915a --- /dev/null +++ b/test/iterator.cpp @@ -0,0 +1,61 @@ +// Boost.Range library +// +// Copyright Neil Groves 2014. Use, modification and +// distribution is 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#include +#include +#include + +#include +#include + +#include + +namespace boost_range_test +{ + namespace + { + +void test_iterator() +{ + typedef std::vector cont; + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::iterator, + boost::range_iterator::type + >::value)); + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::const_iterator, + boost::range_iterator::type + >::value)); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::iterator, + boost::range_iterator::type + >::value)); +#endif +} + + } // anonymous namespace +} // namespace boost_range_test + +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + boost::unit_test::test_suite* test = + BOOST_TEST_SUITE("Boost.Range range_iterator meta-function"); + + test->add(BOOST_TEST_CASE(&boost_range_test::test_iterator)); + + return test; +} diff --git a/test/mutable_iterator.cpp b/test/mutable_iterator.cpp new file mode 100644 index 0000000..40a3879 --- /dev/null +++ b/test/mutable_iterator.cpp @@ -0,0 +1,61 @@ +// Boost.Range library +// +// Copyright Neil Groves 2014. Use, modification and +// distribution is 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#include +#include +#include + +#include +#include + +#include + +namespace boost_range_test +{ + namespace + { + +void test_mutable_iterator() +{ + typedef std::vector cont; + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::iterator, + boost::range_mutable_iterator::type + >::value)); + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::iterator, + boost::range_mutable_iterator::type + >::value)); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::iterator, + boost::range_mutable_iterator::type + >::value)); +#endif +} + + } // anonymous namespace +} // namespace boost_range_test + +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + boost::unit_test::test_suite* test = + BOOST_TEST_SUITE("Boost.Range range_mutable_iterator meta-function"); + + test->add(BOOST_TEST_CASE(&boost_range_test::test_mutable_iterator)); + + return test; +} diff --git a/test/pointer.cpp b/test/pointer.cpp new file mode 100644 index 0000000..94e78f3 --- /dev/null +++ b/test/pointer.cpp @@ -0,0 +1,61 @@ +// Boost.Range library +// +// Copyright Neil Groves 2014. Use, modification and +// distribution is 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#include +#include +#include + +#include +#include + +#include + +namespace boost_range_test +{ + namespace + { + +void test_pointer() +{ + typedef std::vector cont; + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::pointer, + boost::range_pointer::type + >::value)); + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::const_pointer, + boost::range_pointer::type + >::value)); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::pointer, + boost::range_pointer::type + >::value)); +#endif +} + + } // anonymous namespace +} // namespace boost_range_test + +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + boost::unit_test::test_suite* test = + BOOST_TEST_SUITE("Boost.Range range_pointer meta-function"); + + test->add(BOOST_TEST_CASE(&boost_range_test::test_pointer)); + + return test; +} diff --git a/test/reference.cpp b/test/reference.cpp new file mode 100644 index 0000000..755be0e --- /dev/null +++ b/test/reference.cpp @@ -0,0 +1,61 @@ +// Boost.Range library +// +// Copyright Neil Groves 2014. Use, modification and +// distribution is 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#include +#include +#include + +#include +#include + +#include + +namespace boost_range_test +{ + namespace + { + +void test_reference() +{ + typedef std::vector cont; + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::reference, + boost::range_reference::type + >::value)); + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::const_reference, + boost::range_reference::type + >::value)); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::reference, + boost::range_reference::type + >::value)); +#endif +} + + } // anonymous namespace +} // namespace boost_range_test + +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + boost::unit_test::test_suite* test = + BOOST_TEST_SUITE("Boost.Range range_reference meta-function"); + + test->add(BOOST_TEST_CASE(&boost_range_test::test_reference)); + + return test; +} diff --git a/test/result_iterator.cpp b/test/result_iterator.cpp new file mode 100644 index 0000000..88dd7a5 --- /dev/null +++ b/test/result_iterator.cpp @@ -0,0 +1,61 @@ +// Boost.Range library +// +// Copyright Neil Groves 2014. Use, modification and +// distribution is 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#include +#include +#include + +#include +#include + +#include + +namespace boost_range_test +{ + namespace + { + +void test_result_iterator() +{ + typedef std::vector cont; + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::iterator, + boost::range_result_iterator::type + >::value)); + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::const_iterator, + boost::range_result_iterator::type + >::value)); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::iterator, + boost::range_result_iterator::type + >::value)); +#endif +} + + } // anonymous namespace +} // namespace boost_range_test + +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + boost::unit_test::test_suite* test = + BOOST_TEST_SUITE("Boost.Range range_result_iterator meta-function"); + + test->add(BOOST_TEST_CASE(&boost_range_test::test_result_iterator)); + + return test; +} diff --git a/test/reverse_iterator.cpp b/test/reverse_iterator.cpp new file mode 100644 index 0000000..827f244 --- /dev/null +++ b/test/reverse_iterator.cpp @@ -0,0 +1,61 @@ +// Boost.Range library +// +// Copyright Neil Groves 2014. Use, modification and +// distribution is 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#include +#include +#include + +#include +#include + +#include + +namespace boost_range_test +{ + namespace + { + +void test_reverse_iterator() +{ + typedef std::vector cont; + + BOOST_STATIC_ASSERT(( + boost::is_same< + boost::reverse_iterator, + boost::range_reverse_iterator::type + >::value)); + + BOOST_STATIC_ASSERT(( + boost::is_same< + boost::reverse_iterator, + boost::range_reverse_iterator::type + >::value)); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_ASSERT(( + boost::is_same< + boost::reverse_iterator, + boost::range_reverse_iterator::type + >::value)); +#endif +} + + } // anonymous namespace +} // namespace boost_range_test + +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + boost::unit_test::test_suite* test = + BOOST_TEST_SUITE("Boost.Range range_reverse_iterator meta-function"); + + test->add(BOOST_TEST_CASE(&boost_range_test::test_reverse_iterator)); + + return test; +} diff --git a/test/reverse_result_iterator.cpp b/test/reverse_result_iterator.cpp new file mode 100644 index 0000000..7d160fe --- /dev/null +++ b/test/reverse_result_iterator.cpp @@ -0,0 +1,62 @@ +// Boost.Range library +// +// Copyright Neil Groves 2014. Use, modification and +// distribution is 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#include +#include +#include + +#include +#include + +#include + +namespace boost_range_test +{ + namespace + { + +void test_reverse_result_iterator() +{ + typedef std::vector cont; + + BOOST_STATIC_ASSERT(( + boost::is_same< + boost::reverse_iterator, + boost::range_reverse_result_iterator::type + >::value)); + + BOOST_STATIC_ASSERT(( + boost::is_same< + boost::reverse_iterator, + boost::range_reverse_result_iterator::type + >::value)); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_ASSERT(( + boost::is_same< + boost::reverse_iterator, + boost::range_reverse_result_iterator::type + >::value)); +#endif +} + + } // anonymous namespace +} // namespace boost_range_test + +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + boost::unit_test::test_suite* test = + BOOST_TEST_SUITE( + "Boost.Range range_reverse_result_iterator meta-function"); + + test->add(BOOST_TEST_CASE(&boost_range_test::test_reverse_result_iterator)); + + return test; +} diff --git a/test/size_type.cpp b/test/size_type.cpp new file mode 100644 index 0000000..9c335f1 --- /dev/null +++ b/test/size_type.cpp @@ -0,0 +1,61 @@ +// Boost.Range library +// +// Copyright Neil Groves 2014. Use, modification and +// distribution is 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#include +#include +#include + +#include +#include + +#include + +namespace boost_range_test +{ + namespace + { + +void test_size() +{ + typedef std::vector cont; + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::size_type, + boost::range_size::type + >::value)); + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::size_type, + boost::range_size::type + >::value)); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::size_type, + boost::range_size::type + >::value)); +#endif +} + + } // anonymous namespace +} // namespace boost_range_test + +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + boost::unit_test::test_suite* test = + BOOST_TEST_SUITE("Boost.Range range_size meta-function"); + + test->add(BOOST_TEST_CASE(&boost_range_test::test_size)); + + return test; +} diff --git a/test/value_type.cpp b/test/value_type.cpp new file mode 100644 index 0000000..9a18b2f --- /dev/null +++ b/test/value_type.cpp @@ -0,0 +1,61 @@ +// Boost.Range library +// +// Copyright Neil Groves 2014. Use, modification and +// distribution is 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) +// +// For more information, see http://www.boost.org/libs/range/ +// + +#include +#include +#include + +#include +#include + +#include + +namespace boost_range_test +{ + namespace + { + +void test_value_type() +{ + typedef std::vector cont; + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::value_type, + boost::range_value::type + >::value)); + + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::value_type, + boost::range_value::type + >::value)); + +#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES + BOOST_STATIC_ASSERT(( + boost::is_same< + cont::value_type, + boost::range_value::type + >::value)); +#endif +} + + } // anonymous namespace +} // namespace boost_range_test + +boost::unit_test::test_suite* init_unit_test_suite( int argc, char* argv[] ) +{ + boost::unit_test::test_suite* test = + BOOST_TEST_SUITE("Boost.Range range_value meta-function"); + + test->add(BOOST_TEST_CASE(&boost_range_test::test_value_type)); + + return test; +}