diff --git a/include/boost/detail/container_fwd.hpp b/include/boost/detail/container_fwd.hpp index 9a21252..1a58935 100644 --- a/include/boost/detail/container_fwd.hpp +++ b/include/boost/detail/container_fwd.hpp @@ -18,7 +18,8 @@ && (defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_PARALLEL))) \ || BOOST_WORKAROUND(__BORLANDC__, > 0x551) \ || BOOST_WORKAROUND(__DMC__, BOOST_TESTED_AT(0x842)) \ - || (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) + || (defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)) \ + || (defined(_LIBCPP_VERSION)) #include #include diff --git a/test/Jamfile b/test/Jamfile new file mode 100644 index 0000000..9413621 --- /dev/null +++ b/test/Jamfile @@ -0,0 +1,21 @@ +################################################################*# Jam #*####### +# Copyright (C) 2010 Bryce Lelbach +# +# Distributed under 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) +################################################################################ + +project detail/test + : requirements + clang:-Wno-unused + clang:-Wno-tautological-compare + clang:-ftemplate-depth-300 + gcc:-ftemplate-depth-300 + darwin:-ftemplate-depth-300 + ; + +for tests in [ glob *.cpp ] { + run $(tests) : : : : $(tests:B) ; +} + + diff --git a/test/container_fwd_test.cpp b/test/container_fwd_test.cpp new file mode 100644 index 0000000..55c2e04 --- /dev/null +++ b/test/container_fwd_test.cpp @@ -0,0 +1,112 @@ + +// Copyright 2005-2009 Daniel James. +// Distributed under 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) + +#include + +#if BOOST_WORKAROUND(__GNUC__, < 3) && \ + !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) +template +static void test( + std::basic_string, Allocator> const&) +{ +} +#else +template +static void test( + std::basic_string, Allocator> const&) +{ +} +#endif + +template +static void test(std::deque const&) +{ +} + +template +static void test(std::list const&) +{ +} + +template +static void test(std::vector const&) +{ +} + +template +static void test(std::map const&) +{ +} + +template +static void test(std::multimap const&) +{ +} + +template +static void test(std::set const&) +{ +} + +template +static void test(std::multiset const&) +{ +} + +template +static void test(std::bitset const&) +{ +} + +template +static void test(std::complex const&) +{ +} + +template +static void test(std::pair const&) +{ +} + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +int main() +{ + std::deque x1; + std::list x2; + std::vector x3; + std::vector x4; + std::map x5; + std::multimap x6; + std::set x7; + std::multiset > x8; + std::bitset<10> x9; + std::string x10; + std::complex x11; + std::pair, char***> x12; + + test(x1); + test(x2); + test(x3); + test(x4); + test(x5); + test(x6); + test(x7); + test(x8); + test(x9); + test(x10); + test(x11); + test(x12); + + return 0; +} diff --git a/test/container_no_fwd_test.cpp b/test/container_no_fwd_test.cpp new file mode 100644 index 0000000..9da09da --- /dev/null +++ b/test/container_no_fwd_test.cpp @@ -0,0 +1,14 @@ + +// Copyright 2010 Daniel James. +// Distributed under 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) + +#define BOOST_DETAIL_NO_CONTAINER_FWD + +#include + +int main() +{ + std::set x; + std::vector y; +} diff --git a/test/is_sorted_test.cpp b/test/is_sorted_test.cpp new file mode 100644 index 0000000..036c10a --- /dev/null +++ b/test/is_sorted_test.cpp @@ -0,0 +1,130 @@ +/*============================================================================== + Copyright (c) 2010-2011 Bryce Lelbach + + Distributed under 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) +==============================================================================*/ + +#include +#include +#include +#include +#include + +template +struct tracking_less: std::binary_function { + typedef bool result_type; + + #if defined(__PATHSCALE__) + tracking_less (void) { } + ~tracking_less (void) { } + #endif + + bool operator() (T const& x, T const& y) const { + std::cout << x << " < " << y << " == " << (x < y) << "\n"; + return x < y; + } +}; + +template +struct tracking_less_equal: std::binary_function { + typedef bool result_type; + + #if defined(__PATHSCALE__) + tracking_less_equal (void) { } + ~tracking_less_equal (void) { } + #endif + + bool operator() (T const& x, T const& y) const { + std::cout << x << " <= " << y << " == " << (x <= y) << "\n"; + return x <= y; + } +}; + +template +struct tracking_greater: std::binary_function { + typedef bool result_type; + + #if defined(__PATHSCALE__) + tracking_greater (void) { } + ~tracking_greater (void) { } + #endif + + bool operator() (T const& x, T const& y) const { + std::cout << x << " > " << y << " == " << (x > y) << "\n"; + return x > y; + } +}; + +template +struct tracking_greater_equal: std::binary_function { + typedef bool result_type; + + #if defined(__PATHSCALE__) + tracking_greater_equal (void) { } + ~tracking_greater_equal (void) { } + #endif + + bool operator() (T const& x, T const& y) const { + std::cout << x << " >= " << y << " == " << (x >= y) << "\n"; + return x >= y; + } +}; + + +int main (void) { + #define IS_SORTED ::boost::detail::is_sorted + #define IS_SORTED_UNTIL ::boost::detail::is_sorted_until + using boost::array; + using boost::report_errors; + + std::cout << std::boolalpha; + + array a = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } }; + array b = { { 0, 1, 1, 2, 5, 8, 13, 34, 55, 89 } }; + array c = { { 0, 1, -1, 2, -3, 5, -8, 13, -21, 34 } }; + + tracking_less lt; + tracking_less_equal lte; + tracking_greater gt; + tracking_greater_equal gte; + + BOOST_TEST_EQ(IS_SORTED_UNTIL(a.begin(), a.end()), a.end()); + BOOST_TEST_EQ(IS_SORTED_UNTIL(a.begin(), a.end(), lt), a.end()); + BOOST_TEST_EQ(IS_SORTED_UNTIL(a.begin(), a.end(), lte), a.end()); + BOOST_TEST_EQ(*IS_SORTED_UNTIL(a.rbegin(), a.rend(), gt), *a.rend()); + BOOST_TEST_EQ(*IS_SORTED_UNTIL(a.rbegin(), a.rend(), gte), *a.rend()); + + BOOST_TEST_EQ(IS_SORTED(a.begin(), a.end()), true); + BOOST_TEST_EQ(IS_SORTED(a.begin(), a.end(), lt), true); + BOOST_TEST_EQ(IS_SORTED(a.begin(), a.end(), lte), true); + BOOST_TEST_EQ(IS_SORTED(a.rbegin(), a.rend(), gt), true); + BOOST_TEST_EQ(IS_SORTED(a.rbegin(), a.rend(), gte), true); + + BOOST_TEST_EQ(IS_SORTED_UNTIL(b.begin(), b.end()), b.end()); + BOOST_TEST_EQ(IS_SORTED_UNTIL(b.begin(), b.end(), lt), b.end()); + BOOST_TEST_EQ(IS_SORTED_UNTIL(b.begin(), b.end(), lte), &b[2]); + BOOST_TEST_EQ(*IS_SORTED_UNTIL(b.rbegin(), b.rend(), gt), *b.rend()); + BOOST_TEST_EQ(*IS_SORTED_UNTIL(b.rbegin(), b.rend(), gte), b[2]); + + BOOST_TEST_EQ(IS_SORTED(b.begin(), b.end()), true); + BOOST_TEST_EQ(IS_SORTED(b.begin(), b.end(), lt), true); + BOOST_TEST_EQ(IS_SORTED(b.begin(), b.end(), lte), false); + BOOST_TEST_EQ(IS_SORTED(b.rbegin(), b.rend(), gt), true); + BOOST_TEST_EQ(IS_SORTED(b.rbegin(), b.rend(), gte), false); + + BOOST_TEST_EQ(IS_SORTED_UNTIL(c.begin(), c.end()), &c[2]); + BOOST_TEST_EQ(IS_SORTED_UNTIL(c.begin(), c.end(), lt), &c[2]); + BOOST_TEST_EQ(IS_SORTED_UNTIL(c.begin(), c.end(), lte), &c[2]); + BOOST_TEST_EQ(*IS_SORTED_UNTIL(c.rbegin(), c.rend(), gt), c[7]); + BOOST_TEST_EQ(*IS_SORTED_UNTIL(c.rbegin(), c.rend(), gte), c[7]); + + BOOST_TEST_EQ(IS_SORTED(c.begin(), c.end()), false); + BOOST_TEST_EQ(IS_SORTED(c.begin(), c.end(), lt), false); + BOOST_TEST_EQ(IS_SORTED(c.begin(), c.end(), lte), false); + BOOST_TEST_EQ(IS_SORTED(c.rbegin(), c.rend(), gt), false); + BOOST_TEST_EQ(IS_SORTED(c.rbegin(), c.rend(), gte), false); + + return report_errors(); +} +