// (C) Copyright John Maddock 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) #ifdef TEST_STD_HEADERS #include #include #include #else #include #include #include #endif #include #include #include "verify_return.hpp" struct strict_comparison1{}; struct strict_comparison2 { strict_comparison2(); strict_comparison2(const strict_comparison1&); strict_comparison2(const strict_comparison2&); strict_comparison2& operator=(const strict_comparison2&); strict_comparison2& operator=(const strict_comparison1&); }; bool operator==(const strict_comparison1&, const strict_comparison1&); bool operator<(const strict_comparison1&, const strict_comparison1&); bool operator==(const strict_comparison2&, const strict_comparison2&); bool operator<(const strict_comparison2&, const strict_comparison2&); bool operator==(const strict_comparison1&, const strict_comparison2&); bool operator<(const strict_comparison1&, const strict_comparison2&); bool operator==(const strict_comparison2&, const strict_comparison1&); bool operator<(const strict_comparison2&, const strict_comparison1&); int main() { std::tr1::tuple t1a; std::tr1::tuple t1b(0); std::tr1::tuple t1c(t1b); t1a = t1c; std::tr1::tuple t1d(std::tr1::tuple(0)); t1a = std::tr1::tuple(0); std::tr1::tuple t2a; std::tr1::tuple t2b(0, 0); std::tr1::tuple t2c(t2b); t2a = t2c; std::tr1::tuple t2d(std::tr1::tuple(0, 0)); t2a = std::tr1::tuple(0, 0); std::tr1::tuple t2e(std::make_pair(0, 0L)); t2e = std::make_pair(0, 0L); // check implementation limits: std::tr1::tuple t10(0, 0, 0, 0, 0, 0, 0, 0, 0); // make_tuple: verify_return_type(std::tr1::make_tuple(0, 0, 0L), std::tr1::tuple()); int i = 0; std::tr1::tuple t3a(std::tr1::make_tuple(std::tr1::ref(i), 0, 0L)); verify_return_type(std::tr1::make_tuple(std::tr1::ref(i), 0, 0L), t3a); std::tr1::tuple t3b(std::tr1::make_tuple(std::tr1::cref(i), 0, 0L)); verify_return_type(std::tr1::make_tuple(std::tr1::cref(i), 0, 0L), t3b); long j = 0; std::tr1::tuple tt(std::tr1::tie(i,j)); BOOST_STATIC_ASSERT((::std::tr1::tuple_size >::value == 2)); BOOST_STATIC_ASSERT((::std::tr1::tuple_size >::value == 9)); BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::tr1::tuple >::type, int>::value)); BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<1, std::tr1::tuple >::type, long>::value)); BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::tr1::tuple >::type, int&>::value)); BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::tr1::tuple >::type, const int&>::value)); // get: verify_return_type(&::std::tr1::get<0>(t1a), static_cast(0)); verify_return_type(&::std::tr1::get<1>(t2d), static_cast(0)); verify_return_type(&::std::tr1::get<0>(t3a), static_cast(0)); verify_return_type(&::std::tr1::get<0>(t3b), static_cast(0)); const std::tr1::tuple& cr1 = t1a; verify_return_type(&::std::tr1::get<0>(cr1), static_cast(0)); const std::tr1::tuple& cr2 = t3a; verify_return_type(&::std::tr1::get<0>(cr2), static_cast(0)); const std::tr1::tuple& cr3 = t3b; // comparison: verify_return_type(cr2 == cr3, false); verify_return_type(cr2 != cr3, false); verify_return_type(cr2 < cr3, false); verify_return_type(cr2 > cr3, false); verify_return_type(cr2 <= cr3, false); verify_return_type(cr2 >= cr3, false); // strict comparisons: const std::tr1::tuple comp1, comp2; verify_return_type(comp1 == comp2, false); verify_return_type(comp1 != comp2, false); verify_return_type(comp1 < comp2, false); verify_return_type(comp1 > comp2, false); verify_return_type(comp1 <= comp2, false); verify_return_type(comp1 >= comp2, false); // test strict mixed comparisons const std::tr1::tuple comp3; verify_return_type(comp1 == comp3, false); verify_return_type(comp1 != comp3, false); verify_return_type(comp1 < comp3, false); verify_return_type(comp1 > comp3, false); verify_return_type(comp1 <= comp3, false); verify_return_type(comp1 >= comp3, false); verify_return_type(comp3 == comp2, false); verify_return_type(comp3 != comp2, false); verify_return_type(comp3 < comp2, false); verify_return_type(comp3 > comp2, false); verify_return_type(comp3 <= comp2, false); verify_return_type(comp3 >= comp2, false); // test mixed construct and assign: const std::tr1::tuple cons1; std::tr1::tuple cons2(cons1); cons2 = cons1; const std::pair p1; std::tr1::tuple cons3(p1); cons3 = p1; // pair interface: BOOST_STATIC_ASSERT((::std::tr1::tuple_size >::value == 2)); BOOST_STATIC_ASSERT((::std::tr1::tuple_size >::value == 2)); BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::pair >::type, int>::value)); BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<1, std::pair >::type, long>::value)); std::pair p2; const std::pair& p3 = p2; verify_return_type(&std::tr1::get<0>(p2), static_cast(0)); verify_return_type(&std::tr1::get<1>(p2), static_cast(0)); verify_return_type(&std::tr1::get<0>(p3), static_cast(0)); verify_return_type(&std::tr1::get<1>(p3), static_cast(0)); return 0; }