// Copyright 2005-2007 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) #if defined(BOOST_MSVC) #pragma warning(push) #pragma warning(disable:4100) // unreferenced formal parameter #endif #include #if defined(BOOST_MSVC) #pragma warning(pop) #endif #include #include #include #include #include #include #include "../helpers/check_return_type.hpp" typedef long double comparison_type; template void sink(T const&) {} template void container_test(X& r, T&) { typedef typename X::iterator iterator; typedef typename X::const_iterator const_iterator; typedef typename X::difference_type difference_type; typedef typename X::size_type size_type; typedef typename boost::iterator_value::type iterator_value_type; typedef typename boost::iterator_value::type const_iterator_value_type; typedef typename boost::iterator_difference::type iterator_difference_type; typedef typename boost::iterator_difference::type const_iterator_difference_type; typedef typename X::value_type value_type; typedef typename X::reference reference; typedef typename X::const_reference const_reference; // value_type BOOST_MPL_ASSERT((boost::is_same)); boost::function_requires >(); // reference_type / const_reference_type BOOST_MPL_ASSERT((boost::is_same)); BOOST_MPL_ASSERT((boost::is_same)); // iterator boost::function_requires >(); BOOST_MPL_ASSERT((boost::is_same)); BOOST_MPL_ASSERT((boost::is_convertible)); // const_iterator boost::function_requires >(); BOOST_MPL_ASSERT((boost::is_same)); // difference_type BOOST_MPL_ASSERT((boost::mpl::bool_< std::numeric_limits::is_signed>)); BOOST_MPL_ASSERT((boost::mpl::bool_< std::numeric_limits::is_integer>)); BOOST_MPL_ASSERT((boost::is_same)); BOOST_MPL_ASSERT((boost::is_same)); // size_type BOOST_MPL_ASSERT_NOT((boost::mpl::bool_< std::numeric_limits::is_signed>)); BOOST_MPL_ASSERT((boost::mpl::bool_< std::numeric_limits::is_integer>)); // size_type can represent any non-negative value type of difference_type // I'm not sure about either of these tests... size_type max_diff((std::numeric_limits::max)()); difference_type converted_diff(max_diff); BOOST_TEST((std::numeric_limits::max)() == converted_diff); BOOST_TEST( static_cast( (std::numeric_limits::max)()) > static_cast( (std::numeric_limits::max)())); // I don't test the runtime post-conditions here. X u; BOOST_TEST(u.size() == 0); BOOST_TEST(X().size() == 0); X a,b; sink(X(a)); X u2(a); X u3 = a; X* ptr = new X(); X& a1 = *ptr; (&a1)->~X(); X const a_const; test::check_return_type::equals(a.begin()); test::check_return_type::equals(a_const.begin()); test::check_return_type::equals(a.cbegin()); test::check_return_type::equals(a_const.cbegin()); test::check_return_type::equals(a.end()); test::check_return_type::equals(a_const.end()); test::check_return_type::equals(a.cend()); test::check_return_type::equals(a_const.cend()); } template void equality_test(X& r, T&) { X const a = r, b = r; test::check_return_type::equals(a == b); test::check_return_type::equals(a != b); #if defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) test::check_return_type::equals(boost::hash_value(a)); #else test::check_return_type::equals(hash_value(a)); #endif }