? boost/tuple/detail/bak.hpp ? libs/tuple/test/NativeLog.txt ? libs/tuple/test/temp.tmp cvs server: Diffing boost/tuple cvs server: Diffing boost/tuple/detail Index: boost/tuple/detail/tuple_basic_no_partial_spec.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/tuple/detail/tuple_basic_no_partial_spec.hpp,v retrieving revision 1.13 diff -w -u -r1.13 tuple_basic_no_partial_spec.hpp --- boost/tuple/detail/tuple_basic_no_partial_spec.hpp 20 Nov 2002 13:17:52 -0000 1.13 +++ boost/tuple/detail/tuple_basic_no_partial_spec.hpp 5 Sep 2003 16:22:02 -0000 @@ -68,6 +68,10 @@ > class tuple; +// forward declaration of cons + template + struct cons; + namespace detail { // Takes a pointer and routes all assignments to whatever it points to @@ -99,10 +103,63 @@ }; template struct add_const_reference : add_reference::type> {}; + + template + struct init_tail + { + // Each of vc6 and vc7 seem to require a different formulation + // of this return type + template +#if BOOST_WORKAROUND(BOOST_MSVC, == 1200) + static typename add_const::type>::type +#else + static typename add_const_reference::type +#endif + execute( cons const& u, long ) + { + return u.get_tail(); + } + }; + + template <> + struct init_tail + { + template + static null_type execute( cons const& u, long ) + { + return null_type(); + } + + template + static null_type execute(U const&, ...) + { + return null_type(); + } + private: + template + void execute( cons const&, int); + }; + + template + Other const& + init_head( Other const& u, ... ) + { + return u; + } + + template + typename add_reference::type>::type + init_head( cons const& u, int ) + { + return u.get_head(); + } + + inline char**** init_head(null_type const&, int); + } // end of namespace detail // cons builds a heterogenous list of types - template + template struct cons { typedef cons self_type; @@ -124,14 +181,16 @@ head_cref get_head() const { return head; } tail_cref get_tail() const { return tail; } + cons() : head(), tail() {} + #if defined BOOST_MSVC template - explicit cons(head_cref h /* = head_type() */, // causes MSVC 6.5 to barf. + cons(head_cref h /* = head_type() */, // causes MSVC 6.5 to barf. const Tail& t) : head(h), tail(t.head, t.tail) { } - explicit cons(head_cref h /* = head_type() */, // causes MSVC 6.5 to barf. + cons(head_cref h /* = head_type() */, // causes MSVC 6.5 to barf. const null_type& t) : head(h), tail(t) { } @@ -150,6 +209,12 @@ } #endif + template + cons( const U& u ) + : head(detail::init_head(u, 0)) + , tail(detail::init_tail::execute(u, 0L)) + { + } template cons& operator=(const Other& other) @@ -437,8 +502,12 @@ typedef cons1 inherited; typedef tuple self_type; - explicit tuple(t1_cref t1 = T1(), - t2_cref t2 = T2(), + tuple() : cons1(T1(), cons2(T2(), cons3(T3(), cons4(T4(), cons5(T5(), cons6(T6(),cons7(T7(),cons8(T8(),cons9(T9(),cons10(T10())))))))))) + {} + + tuple( + t1_cref t1, + t2_cref t2, t3_cref t3 = T3(), t4_cref t4 = T4(), t5_cref t5 = T5(), @@ -452,8 +521,12 @@ { } + explicit tuple(t1_cref t1) + : cons1(t1, cons2(T2(), cons3(T3(), cons4(T4(), cons5(T5(), cons6(T6(),cons7(T7(),cons8(T8(),cons9(T9(),cons10(T10())))))))))) + {} + template - explicit tuple(const cons& other) : + tuple(const cons& other) : cons1(other.head, other.tail) { } cvs server: Diffing libs/tuple cvs server: Diffing libs/tuple/doc cvs server: Diffing libs/tuple/test Index: libs/tuple/test/another_tuple_test_bench.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/tuple/test/another_tuple_test_bench.cpp,v retrieving revision 1.5 diff -w -u -r1.5 another_tuple_test_bench.cpp --- libs/tuple/test/another_tuple_test_bench.cpp 4 Feb 2003 11:54:00 -0000 1.5 +++ libs/tuple/test/another_tuple_test_bench.cpp 5 Sep 2003 16:22:02 -0000 @@ -103,7 +103,6 @@ void foo4() { -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) double d = 2.7; A a; tuple t(1, d, a); @@ -118,8 +117,6 @@ #endif #ifdef E10 dummy(get<5>(ct)); // illegal index -#endif - #endif } Index: libs/tuple/test/tuple_test_bench.cpp =================================================================== RCS file: /cvsroot/boost/boost/libs/tuple/test/tuple_test_bench.cpp,v retrieving revision 1.19 diff -w -u -r1.19 tuple_test_bench.cpp --- libs/tuple/test/tuple_test_bench.cpp 26 Jun 2003 15:19:01 -0000 1.19 +++ libs/tuple/test/tuple_test_bench.cpp 5 Sep 2003 16:22:02 -0000 @@ -22,6 +22,7 @@ #include "boost/type_traits/is_const.hpp" +#include "boost/ref.hpp" #include #include @@ -81,7 +82,6 @@ typedef tuple t1; -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) typedef tuple t2; typedef tuple t3; typedef tuple > t4; @@ -92,22 +92,16 @@ typedef tuple t7; #endif -#endif - // ----------------------------------------------------------------------- // -tuple construction tests --------------------------------------------- // ----------------------------------------------------------------------- -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) no_copy y; tuple x = tuple(y); // ok -#endif -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) char cs[10]; tuple v2(cs); // ok -#endif void construction_test() @@ -162,12 +156,10 @@ // dummy(tuple()); // should fail, not defaults for references // dummy(tuple()); // likewise -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) double dd = 5; dummy(tuple(dd)); // ok dummy(tuple(dd+3.14)); // ok, but dangerous -#endif // dummy(tuple(dd+3.14)); // should fail, // // temporary to non-const reference @@ -180,7 +172,6 @@ void element_access_test() { -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) double d = 2.7; A a; tuple t(1, d, a, 2); @@ -211,45 +202,18 @@ ++get<0>(t); BOOST_TEST(get<0>(t) == 6); - using boost::tuples::element; - - BOOST_STATIC_ASSERT((boost::is_const >::type>::value != true)); - BOOST_STATIC_ASSERT((boost::is_const >::type>::value)); + BOOST_STATIC_ASSERT((boost::is_const >::type>::value != true)); +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + BOOST_STATIC_ASSERT((boost::is_const >::type>::value)); +#endif - BOOST_STATIC_ASSERT((boost::is_const >::type>::value != true)); - BOOST_STATIC_ASSERT((boost::is_const >::type>::value)); + BOOST_STATIC_ASSERT((boost::is_const >::type>::value != true)); +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + BOOST_STATIC_ASSERT((boost::is_const >::type>::value)); +#endif dummy(i); dummy(i2); dummy(j); dummy(e); // avoid warns for unused variables -#else - double d = 2.7; - A a; - tuple t(1, d, a, 2); - - int i = get<0>(t); - int i2 = get<3>(t); - - BOOST_TEST(i == 1 && i2 == 2); - - get<0>(t) = 5; - BOOST_TEST(t.head == 5); - - // get<0>(ct) = 5; // can't assign to const - - double e = get<1>(t); - BOOST_TEST(e > 2.69 && e < 2.71); - - get<1>(t) = 3.14+i; - BOOST_TEST(get<1>(t) > 4.13 && get<1>(t) < 4.15); - - // get<4>(t) = A(); // can't assign to const - // dummy(get<5>(ct)); // illegal index - - ++get<0>(t); - BOOST_TEST(get<0>(t) == 6); - - dummy(i); dummy(i2); dummy(e); // avoid warns for unused variables -#endif } @@ -320,31 +284,27 @@ BOOST_TEST(get<1>(t2) == "Hi"); -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) A a = A(); B b; const A ca = a; - make_tuple(cref(a), b); - make_tuple(ref(a), b); - make_tuple(ref(a), cref(b)); + make_tuple(boost::cref(a), b); + make_tuple(boost::ref(a), b); + make_tuple(boost::ref(a), boost::cref(b)); - make_tuple(ref(ca)); -#endif + make_tuple(boost::ref(ca)); // the result of make_tuple is assignable: BOOST_TEST(make_tuple(2, 4, 6) == (make_tuple(1, 2, 3) = make_tuple(2, 4, 6))); -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) +#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION make_tuple("Donald", "Daisy"); // should work; #endif // std::make_pair("Doesn't","Work"); // fails // You can store a reference to a function in a tuple -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) tuple adf(make_tuple_test); dummy(adf); // avoid warning for unused variable -#endif // But make_tuple doesn't work // with function references, since it creates a const qualified function type @@ -450,7 +410,6 @@ // ---------------------------------------------------------------------------- void cons_test() { -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) using tuples::cons; using tuples::null_type; @@ -462,7 +421,6 @@ cons > > x; dummy(x); -#endif } // ----------------------------------------------------------------------------