stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elemi...@apache.org
Subject svn commit: r675044 - in /stdcxx/branches/4.3.x: include/rw/_tuple.h include/tuple tests/utilities/20.tuple.cnstr.cpp tests/utilities/20.tuple.creation.cpp tests/utilities/20.tuple.h tests/utilities/20.tuple.helpers.cpp
Date Tue, 08 Jul 2008 23:13:36 GMT
Author: elemings
Date: Tue Jul  8 16:13:36 2008
New Revision: 675044

URL: http://svn.apache.org/viewvc?rev=675044&view=rev
Log:
2008-07-08  Eric Lemings <eric.lemings@roguewave.com>

	STDCXX-958
	* include/tuple: Second parameter in value move ctor of pair
	specialization missing rvalue reference.
	(make_tuple, get, relational operators): Explicitly declare
	as inline functions.
	(tie): Implemented.
	* include/rw/_tuple.h: Fix move semantics in heterogenous move
	assignment operator.
	(__rw_ignore): Add assignment operator to ignore all values.
	* tests/utilities/20.tuple.cnstr.cpp: Added V&V for tuple
	state and invariants.  Manually inspected proper construction
	of all test tuples.  Updated/corrected/added tests as necessary.
	* tests/utilities/20.tuple.creation.cpp: Added simple tie()
	test.
	* tests/utilities/20.tuple.h: Minor stylistic changes.
	* tests/utilities/20.tuple.helpers.cpp: Same.


Modified:
    stdcxx/branches/4.3.x/include/rw/_tuple.h
    stdcxx/branches/4.3.x/include/tuple
    stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp
    stdcxx/branches/4.3.x/tests/utilities/20.tuple.creation.cpp
    stdcxx/branches/4.3.x/tests/utilities/20.tuple.h
    stdcxx/branches/4.3.x/tests/utilities/20.tuple.helpers.cpp

Modified: stdcxx/branches/4.3.x/include/rw/_tuple.h
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/rw/_tuple.h?rev=675044&r1=675043&r2=675044&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/include/rw/_tuple.h (original)
+++ stdcxx/branches/4.3.x/include/rw/_tuple.h Tue Jul  8 16:13:36 2008
@@ -127,7 +127,7 @@
 
     template <class _HeadU, class... _TailU>
     __rw_tuple& operator= (__rw_tuple<_HeadU, _TailU...>&& __tuple) {
-        _Base::operator= (_RWSTD_FORWARD (_Base, __tuple._C_tail ()));
+        _Base::operator= (_RWSTD_MOVE (__tuple._C_tail ()));
         _C_data = _RWSTD_MOVE (__tuple._C_head ());
         return *this;
     }
@@ -174,7 +174,14 @@
 };
 
 
-struct __rw_ignore { /* empty */ };
+struct __rw_ignore
+{
+    template <class _TypeT>
+    inline __rw_ignore const&
+    operator= (const _TypeT& /*unused*/) const {
+        return *this;
+    }
+};
 
 
 template <class _TypeT>

Modified: stdcxx/branches/4.3.x/include/tuple
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/tuple?rev=675044&r1=675043&r2=675044&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/include/tuple (original)
+++ stdcxx/branches/4.3.x/include/tuple Tue Jul  8 16:13:36 2008
@@ -211,7 +211,7 @@
 #    if !defined _RWSTD_NO_RVALUE_REFERENCES
 
     template <class _TypeU1, class _TypeU2>
-    _EXPLICIT tuple (_TypeU1&& __x, _TypeU2 __y)
+    _EXPLICIT tuple (_TypeU1&& __x, _TypeU2&& __y)
         : _Base (_RWSTD_FORWARD (_TypeU1, __x),
                  _RWSTD_FORWARD (_TypeU2, __y)) { /* empty */ }
 
@@ -294,7 +294,7 @@
 #    if !defined _RWSTD_NO_RVALUE_REFERENCES
 
 template <class... _TypesT>
-tuple<_TYPENAME _RW::__rw_make_tuple<_TypesT>::_C_type...>
+inline tuple<_TYPENAME _RW::__rw_make_tuple<_TypesT>::_C_type...>
 make_tuple (_TypesT&&... __values)
 {
     typedef tuple<_TYPENAME _RW::__rw_make_tuple<_TypesT>::_C_type...> _Tuple;
@@ -326,7 +326,11 @@
 
 
 template <class... _TypesT>
-tuple<_TypesT&...> tie (_TypesT&...);
+inline tuple<_TypesT&...>
+tie (_TypesT&... __values)
+{
+    return tuple<_TypesT&...> (__values...);
+}
 
 
 // 20.3.1.4, tuple helper classes:
@@ -377,7 +381,7 @@
 // 20.3.1.5, element access:
 
 template <_RWSTD_SIZE_T _Index, class _Head, class... _Tail>
-_TYPENAME tuple_element<_Index, tuple<_Head, _Tail...> >::_Ref
+inline _TYPENAME tuple_element<_Index, tuple<_Head, _Tail...> >::_Ref
 get (tuple<_Head, _Tail...>& __tuple)
 {
     typedef tuple_element<_Index, tuple<_Head, _Tail...> > _Tuple;
@@ -385,7 +389,7 @@
 }
 
 template <_RWSTD_SIZE_T _Index, class _Head, class... _Tail>
-_TYPENAME tuple_element<_Index, tuple<_Head, _Tail...> >::_ConstRef
+inline _TYPENAME tuple_element<_Index, tuple<_Head, _Tail...> >::_ConstRef
 get (const tuple<_Head, _Tail...>& __tuple)
 {
     typedef tuple_element<_Index, tuple<_Head, _Tail...> > _Tuple;
@@ -396,59 +400,67 @@
 // 20.3.1.6, relational operators:
 
 template <class... _TypesT, class... _TypesU>
-bool operator== (const tuple<_TypesT...>& __x,
-                 const tuple<_TypesU...>& __y)
+inline bool
+operator== (const tuple<_TypesT...>& __x,
+            const tuple<_TypesU...>& __y)
 {
     return _RWSTD_STATIC_CAST (const _RW::__rw_tuple<_TypesT...>&, __x)
            == _RWSTD_STATIC_CAST (const _RW::__rw_tuple<_TypesU...>&, __y);
 }
 
 _RWSTD_SPECIALIZED_FUNCTION
-bool operator== (const tuple<>& /*__x*/,
-                 const tuple<>& /*__y*/)
+inline bool
+operator== (const tuple<>& /*__x*/,
+            const tuple<>& /*__y*/)
 {
     return true;
 }
 
 template <class... _TypesT, class... _TypesU>
-bool operator< (const tuple<_TypesT...>& __x,
-                const tuple<_TypesU...>& __y)
+inline bool
+operator< (const tuple<_TypesT...>& __x,
+           const tuple<_TypesU...>& __y)
 {
     return _RWSTD_STATIC_CAST (const _RW::__rw_tuple<_TypesT...>&, __x)
            < _RWSTD_STATIC_CAST (const _RW::__rw_tuple<_TypesU...>&, __y);
 }
 
 _RWSTD_SPECIALIZED_FUNCTION
-bool operator< (const tuple<>& /*__x*/,
-                const tuple<>& /*__y*/)
+inline bool
+operator< (const tuple<>& /*__x*/,
+           const tuple<>& /*__y*/)
 {
     return false;
 }
 
 template <class... _TypesT, class... _TypesU>
-bool operator!= (const tuple<_TypesT...>& __x,
-                 const tuple<_TypesU...>& __y)
+inline bool
+operator!= (const tuple<_TypesT...>& __x,
+            const tuple<_TypesU...>& __y)
 {
     return !(__x == __y);
 }
 
 template <class... _TypesT, class... _TypesU>
-bool operator> (const tuple<_TypesT...>& __x,
-                const tuple<_TypesU...>& __y)
+inline bool
+operator> (const tuple<_TypesT...>& __x,
+           const tuple<_TypesU...>& __y)
 {
     return __y < __x;
 }
 
 template <class... _TypesT, class... _TypesU>
-bool operator<= (const tuple<_TypesT...>& __x,
-                 const tuple<_TypesU...>& __y)
+inline bool
+operator<= (const tuple<_TypesT...>& __x,
+            const tuple<_TypesU...>& __y)
 {
     return !(__y < __x);
 }
 
 template <class... _TypesT, class... _TypesU>
-bool operator>= (const tuple<_TypesT...>& __x,
-                 const tuple<_TypesU...>& __y)
+inline bool
+operator>= (const tuple<_TypesT...>& __x,
+            const tuple<_TypesU...>& __y)
 {
     return !(__x < __y);
 }

Modified: stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp?rev=675044&r1=675043&r2=675044&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp (original)
+++ stdcxx/branches/4.3.x/tests/utilities/20.tuple.cnstr.cpp Tue Jul  8 16:13:36 2008
@@ -32,8 +32,11 @@
 #if    !defined (_RWSTD_NO_EXT_CXX_0X) \
     && !defined(_RWSTD_NO_RVALUE_REFERENCES)
 
+#include <cstring>              // for strcmp
 #include <tuple>
 
+#include <rw_valcmp.h>          // for rw_dblcmp
+
 #include "20.tuple.h"
 
 /**************************************************************************/
@@ -46,7 +49,7 @@
     EmptyTuple et; _RWSTD_UNUSED (et);
     IntTuple it; _RWSTD_UNUSED (it);
     ConstIntTuple ct; _RWSTD_UNUSED (ct);
-    //IntRefTuple rt; _RWSTD_UNUSED (rt); // ill-formed for references
+    // ill-formed for tuples with element types containing references
     PairTuple pt; _RWSTD_UNUSED (pt);
     NestedTuple nt; _RWSTD_UNUSED (nt);
     BigTuple bt; _RWSTD_UNUSED (bt);
@@ -57,80 +60,174 @@
     rw_assert (1 == UserClass::n_total_def_ctor_, __FILE__, __LINE__,
                "tuple<UserClass>::tuple() called %d default ctors, "
                "expected 1", UserClass::n_total_def_ctor_);
-    rw_assert (0 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__,
-               "tuple<UserClass>::tuple() called %d copy ctors, "
-               "expected 0", UserClass::n_total_copy_ctor_);
 }
 
 /**************************************************************************/
 
+#define INT_VALUE       int ('a')
+
+// assume that std::get() has been fully tested and works correctly
+#define VERIFY_TUPLE(it) \
+    rw_assert (std::get<0> (it) == INT_VALUE, __FILE__, __LINE__, \
+               "std::get<0> (" #it "), got %d, expected %d", \
+               std::get<0> (it), INT_VALUE);
+
+
+#define LONG_VALUE      INT_VALUE
+#define STRING_VALUE    "string"
+
 static void
-test_value_copy_ctor ()
+verify_tuple (const PairTuple& pt)
 {
-    rw_info (0, __FILE__, __LINE__, "value copy constructor");
+    rw_assert (std::get<0> (pt) == LONG_VALUE, __FILE__, __LINE__,
+               "std::get<0> (pt), got %d, expected %d",
+               std::get<0> (pt), LONG_VALUE);
+    rw_assert (0 == std::strcmp (std::get<1> (pt), STRING_VALUE),
+               __FILE__, __LINE__,
+               "std::get<1> (pt), got %s, expected %s",
+               std::get<1> (pt), STRING_VALUE);
+}
 
-    int i = 1;
-    IntTuple it1 (i); _RWSTD_UNUSED (it1);
-    const IntTuple it2 (i); _RWSTD_UNUSED (it2);
-    ConstIntTuple ct (i); _RWSTD_UNUSED (ct);
-    IntRefTuple rt (i); _RWSTD_UNUSED (rt);
 
-    NestedTuple nt (it2); _RWSTD_UNUSED (nt);
+#define USER_VALUE      user_val
 
-    const long l = 1;
-    const char* s = "string";
-    PairTuple pt (l, s);
+static UserClass user_val;
 
-    UserClass::reset_totals ();
-    const UserClass uc;
-    UserTuple ut (uc); _RWSTD_UNUSED (ut);
+typedef unsigned int uint_t;
 
-    rw_assert (1 == UserClass::n_total_def_ctor_, __FILE__, __LINE__,
+static void
+verify_tuple (const UserTuple& ut, int line,
+              uint_t dflt = 0, uint_t copy = 0, uint_t asgn = 0)
+{
+    rw_assert (std::get<0> (ut) == USER_VALUE, __FILE__, line,
+               "std::get<0> (ut), got %d, expected %d",
+               (std::get<0> (ut)).data_.val_,
+               USER_VALUE.data_.val_);
+
+    rw_assert (dflt == UserClass::n_total_def_ctor_, __FILE__, line,
                "tuple<UserClass>::tuple() called %d default ctors, "
-               "expected 1", UserClass::n_total_def_ctor_);
-    rw_assert (1 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__,
+               "expected %d", UserClass::n_total_def_ctor_, dflt);
+    rw_assert (copy == UserClass::n_total_copy_ctor_, __FILE__, line,
                "tuple<UserClass>::tuple() called %d copy ctors, "
-               "expected 1", UserClass::n_total_copy_ctor_);
+               "expected %d", UserClass::n_total_copy_ctor_, copy);
+    rw_assert (asgn == UserClass::n_total_op_assign_, __FILE__, line,
+               "tuple<UserClass>::tuple() called %d assign ops, "
+               "expected %d", UserClass::n_total_op_assign_, asgn);
+}
+
 
-    const bool b = true; const char c = 'a';
-    const double d = 1.2; void* const p = 0;
-    BigTuple bt (b, c, i, d, p, uc); _RWSTD_UNUSED (bt);
+#define BOOL_VALUE      true
+#define CHAR_VALUE      'a'
+#define DBL_VALUE       3.14159
+#define PTR_VALUE       ptr_val
+
+static void* ptr_val = 0;
+
+static void
+verify_tuple (const BigTuple& bt)
+{
+    rw_assert (std::get<0> (bt) == BOOL_VALUE, __FILE__, __LINE__,
+               "std::get<0> (bt), got %b, expected %b",
+               std::get<0> (bt), BOOL_VALUE);
+    rw_assert (std::get<1> (bt) == CHAR_VALUE, __FILE__, __LINE__,
+               "std::get<1> (bt), got %c, expected %c",
+               std::get<1> (bt), CHAR_VALUE);
+    rw_assert (std::get<2> (bt) == INT_VALUE, __FILE__, __LINE__,
+               "std::get<2> (bt), got %d, expected %d",
+               std::get<2> (bt), INT_VALUE);
+    int result = rw_dblcmp (std::get<3> (bt), DBL_VALUE);
+    rw_assert (0 == result, __FILE__, __LINE__,
+               "std::get<3> (bt), got %f, expected %f",
+               std::get<3> (bt), DBL_VALUE);
+    rw_assert (std::get<4> (bt) == PTR_VALUE, __FILE__, __LINE__,
+               "std::get<4> (bt), got %p, expected %p",
+               std::get<4> (bt), PTR_VALUE);
+    rw_assert ((std::get<5> (bt)) == USER_VALUE, __FILE__, __LINE__,
+               "std::get<5> (bt), got %d, expected %d",
+               (std::get<5> (bt)).data_.val_, INT_VALUE);
 }
 
 /**************************************************************************/
 
 static void
-test_value_move_ctor ()
+test_value_copy_ctor ()
 {
-    rw_info (0, __FILE__, __LINE__, "value move constructor");
-
-    IntTuple it1 (1); _RWSTD_UNUSED (it1);
-    IntTuple it2 (int ()); _RWSTD_UNUSED (it2);
+    rw_info (0, __FILE__, __LINE__, "value copy constructor");
 
-    const IntTuple it3 (1); _RWSTD_UNUSED (it3);
-    const IntTuple it4 (const IntTuple ()); _RWSTD_UNUSED (it4);
+    const int i = INT_VALUE;
+    IntTuple it1 (i);
+    VERIFY_TUPLE (it1);
 
-    ConstIntTuple ct1 (1); _RWSTD_UNUSED (ct1);
-    ConstIntTuple ct2 (ConstIntTuple ()); _RWSTD_UNUSED (ct2);
+    const IntTuple it2 (i);
+    VERIFY_TUPLE (it2);
 
-    IntRefTuple rt2 (int ()); _RWSTD_UNUSED (rt2);
+    ConstIntTuple ct (i);
+    VERIFY_TUPLE (ct);
 
-    NestedTuple nt (ct1); _RWSTD_UNUSED (nt);
+    int j = INT_VALUE;
+    const IntRefTuple rt (j);
+    VERIFY_TUPLE (rt);
 
-    PairTuple pt (1L, "string"); _RWSTD_UNUSED (pt);
+    NestedTuple nt (it2);
+    VERIFY_TUPLE (std::get<0> (nt));
 
-    BigTuple bt (true, 'a', 1, 1.0, (void*)0, UserClass ());
-    _RWSTD_UNUSED (bt);
+    const long l = LONG_VALUE;
+    const char* s = STRING_VALUE;
+    PairTuple pt (l, s);
+    verify_tuple (pt);
 
     UserClass::reset_totals ();
-    UserTuple ut (UserClass ()); _RWSTD_UNUSED (ut);
+    const UserClass& uc = USER_VALUE;
+    UserTuple ut (uc);
+    verify_tuple (ut, __LINE__, 0, 1);
+
+    const bool b = BOOL_VALUE; const char c = CHAR_VALUE;
+    const double d = DBL_VALUE; void* const p = PTR_VALUE;
+    BigTuple bt (b, c, i, d, p, uc);
+    verify_tuple (bt);
+}
 
-    rw_assert (0 == UserClass::n_total_def_ctor_, __FILE__, __LINE__,
-               "tuple<UserClass>::tuple() called %d default ctors, "
-               "expected 0", UserClass::n_total_def_ctor_);
-    rw_assert (0 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__,
-               "tuple<UserClass>::tuple() called %d copy ctors, "
-               "expected 0", UserClass::n_total_copy_ctor_);
+/**************************************************************************/
+
+static void
+test_value_move_ctor ()
+{
+    rw_info (0, __FILE__, __LINE__, "value move constructor");
+
+    IntTuple it1 (INT_VALUE); // literal constant
+    VERIFY_TUPLE (it1);
+    int i = INT_VALUE;
+    IntTuple it2 (i); // temporary value
+    VERIFY_TUPLE (it2);
+
+    const IntTuple it3 (INT_VALUE);
+    VERIFY_TUPLE (it3);
+    const IntTuple it4 (i);
+    VERIFY_TUPLE (it4);
+
+    ConstIntTuple ct1 (INT_VALUE);
+    VERIFY_TUPLE (ct1);
+    ConstIntTuple ct2 (i);
+    VERIFY_TUPLE (ct2);
+
+    // ill-formed for tuples with element types containing references
+
+    NestedTuple nt (ct1);
+    VERIFY_TUPLE (std::get<0> (nt));
+
+    PairTuple pt (LONG_VALUE, STRING_VALUE);
+    verify_tuple (pt);
+
+    UserClass uc (USER_VALUE);
+    UserClass::reset_totals ();
+    UserTuple ut (uc); // may alter temporary/source value
+    // no move semantics in UserClass currently
+    verify_tuple (ut, __LINE__, 0, 1);
+
+    void* p = PTR_VALUE;
+    uc = USER_VALUE;
+    BigTuple bt (BOOL_VALUE, CHAR_VALUE, INT_VALUE, DBL_VALUE, p, uc);
+    verify_tuple (bt);
 }
 
 /**************************************************************************/
@@ -144,34 +241,36 @@
     EmptyTuple et1, et2 (et1);
     _RWSTD_UNUSED (et2);
 
-    const IntTuple it1;
-    IntTuple it2 (it1); _RWSTD_UNUSED (it2);
-
-    const ConstIntTuple ct1;
-    ConstIntTuple ct2 (ct1); _RWSTD_UNUSED (ct2);
-
-    int i; const IntRefTuple rt1 (i);
-    IntRefTuple rt2 (rt1); _RWSTD_UNUSED (rt2);
-
-    const PairTuple pt1;
-    PairTuple pt2 (pt1); _RWSTD_UNUSED (pt2);
-
-    const NestedTuple nt1;
-    NestedTuple nt2 (nt1); _RWSTD_UNUSED (nt2);
+    const IntTuple it1 (INT_VALUE);
+    IntTuple it2 (it1);
+    VERIFY_TUPLE (it2);
+
+    const ConstIntTuple& ct1 = it1;
+    ConstIntTuple ct2 (ct1);
+    VERIFY_TUPLE (it2);
+
+    int i = INT_VALUE;
+    const IntRefTuple rt1 (i);
+    IntRefTuple rt2 (rt1);
+    VERIFY_TUPLE (rt2);
+
+    const NestedTuple nt1 (it1);
+    NestedTuple nt2 (nt1);
+    VERIFY_TUPLE (std::get<0> (nt2));
+
+    const PairTuple pt1 (LONG_VALUE, STRING_VALUE);
+    PairTuple pt2 (pt1);
+    verify_tuple (pt2);
 
+    const UserTuple ut1 (USER_VALUE);
     UserClass::reset_totals ();
-    const UserTuple ut1; UserTuple ut2 (ut1);
-    _RWSTD_UNUSED (ut1);
+    UserTuple ut2 (ut1);
+    verify_tuple (ut2, __LINE__, 0, 1);
 
-    rw_assert (1 == UserClass::n_total_def_ctor_, __FILE__, __LINE__,
-               "tuple<UserClass>::tuple() called %d default ctors, "
-               "expected 1", UserClass::n_total_def_ctor_);
-    rw_assert (1 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__,
-               "tuple<UserClass>::tuple() called %d copy ctors, "
-               "expected 1", UserClass::n_total_copy_ctor_);
-
-    const BigTuple bt1; BigTuple bt2 (bt1);
-    _RWSTD_UNUSED (bt1); _RWSTD_UNUSED (bt2);
+    const BigTuple bt1 (BOOL_VALUE, CHAR_VALUE, INT_VALUE, DBL_VALUE,
+                        PTR_VALUE, USER_VALUE);
+    BigTuple bt2 (bt1);
+    verify_tuple (bt2);
 }
 
 /**************************************************************************/
@@ -183,20 +282,34 @@
              "move constructor (homogenous tuples)");
 
     EmptyTuple et (EmptyTuple ()); _RWSTD_UNUSED (et);
-    IntTuple it (IntTuple ()); _RWSTD_UNUSED (it);
-    ConstIntTuple ct (ConstIntTuple ()); _RWSTD_UNUSED (ct);
-    PairTuple pt (PairTuple ()); _RWSTD_UNUSED (pt);
-    NestedTuple nt (NestedTuple ()); _RWSTD_UNUSED (nt);
-    BigTuple bt (BigTuple ());
 
+    IntTuple it1 (INT_VALUE);
+    IntTuple it2 (std::move (it1));
+    VERIFY_TUPLE (it2);
+
+    ConstIntTuple ct1 (INT_VALUE);
+    ConstIntTuple ct2 = std::move (ct1);
+    VERIFY_TUPLE (ct2);
+
+    NestedTuple nt1 (it1);
+    NestedTuple nt2 = std::move (nt1);
+    VERIFY_TUPLE (std::get<0> (nt2));
+
+    PairTuple pt1 (LONG_VALUE, STRING_VALUE);
+    PairTuple pt2 (std::move (pt1));
+    verify_tuple (pt2);
+
+    BigTuple bt1 (BOOL_VALUE, CHAR_VALUE, INT_VALUE, DBL_VALUE,
+                  PTR_VALUE, USER_VALUE);
+    BigTuple bt2 (std::move (bt1));
+    verify_tuple (bt2);
+
+    const UserClass& uc = USER_VALUE;
+    UserTuple ut1 (uc);
     UserClass::reset_totals ();
-    UserTuple ut (UserTuple ());
-    rw_assert (0 == UserClass::n_total_def_ctor_, __FILE__, __LINE__,
-               "tuple<UserClass>::tuple() called %d default ctors, "
-               "expected 0", UserClass::n_total_def_ctor_);
-    rw_assert (0 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__,
-               "tuple<UserClass>::tuple() called %d copy ctors, "
-               "expected 0", UserClass::n_total_copy_ctor_);
+    // no move semantics in UserClass currently so it uses copy ctor
+    UserTuple ut2 (std::move (ut1));
+    verify_tuple (ut2, __LINE__, 0, 1);
 }
 
 /**************************************************************************/
@@ -207,24 +320,46 @@
     rw_info (0, __FILE__, __LINE__,
              "copy assignment operator (homogenous tuples)");
 
-    EmptyTuple et1, et2; et2 = et1;
-    IntTuple it1, it2; it2 = it1;
-    //ConstIntTuple ct1, ct2; ct2 = ct1;  // Can't assign to const element.
-    PairTuple pt1, pt2; pt2 = pt1;
-    NestedTuple nt1, nt2; nt2 = nt1;
-    BigTuple bt1, bt2; bt2 = bt1;
+    const EmptyTuple et1 = EmptyTuple ();
+    EmptyTuple et2;
+    et2 = et1;
+    _RWSTD_UNUSED (et2);
 
+    const IntTuple it1 (INT_VALUE);
+    IntTuple it2;
+    it2 = it1;
+    VERIFY_TUPLE (it2);
+
+    // copy assignment ill-formed for constant element types
+
+    int i = INT_VALUE;
+    const IntRefTuple rt1 (i);
+    int j = 0;
+    IntRefTuple rt2 (j); // note, different reference
+    rt2 = rt1;
+    VERIFY_TUPLE (rt2);
+
+    NestedTuple nt1 (it1);
+    NestedTuple nt2;
+    nt2 = nt1;
+    VERIFY_TUPLE (std::get<0> (nt2));
+
+    const PairTuple pt1 (LONG_VALUE, STRING_VALUE);
+    PairTuple pt2;
+    pt2 = pt1;
+    verify_tuple (pt2);
+
+    const BigTuple bt1 (BOOL_VALUE, CHAR_VALUE, INT_VALUE, DBL_VALUE,
+                        PTR_VALUE, USER_VALUE);
+    BigTuple bt2;
+    bt2 = bt1;
+    verify_tuple (bt2);
+
+    const UserTuple ut1 (USER_VALUE);
+    UserTuple ut2;
     UserClass::reset_totals ();
-    UserTuple ut1, ut2; ut1 = ut2;
-    rw_assert (2 == UserClass::n_total_def_ctor_, __FILE__, __LINE__,
-               "tuple<UserClass>::tuple() called %d default ctors, "
-               "expected 2", UserClass::n_total_def_ctor_);
-    rw_assert (0 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__,
-               "tuple<UserClass>::tuple() called %d copy ctors, "
-               "expected 0", UserClass::n_total_copy_ctor_);
-    rw_assert (1 == UserClass::n_total_op_assign_, __FILE__, __LINE__,
-               "tuple<UserClass>::tuple() called %d assign ops, "
-               "expected 1", UserClass::n_total_op_assign_);
+    ut2 = ut1;
+    verify_tuple (ut2, __LINE__, 0, 0, 1);
 }
 
 /**************************************************************************/
@@ -235,45 +370,81 @@
     rw_info (0, __FILE__, __LINE__,
              "move assignment operator (homogenous tuples)");
 
-    EmptyTuple et1, et2; et2 = et1;
-    IntTuple it1, it2; it2 = it1;
-    //ConstIntTuple ct1, ct2; ct2 = ct1;  // Can't assign to const element.
-    PairTuple pt1, pt2; pt2 = pt1;
-    NestedTuple nt1, nt2; nt2 = nt1;
-    BigTuple bt1, bt2; bt2 = bt1;
+    EmptyTuple et1, et2;
+    et2 = std::move (et1);
+    _RWSTD_UNUSED (et2);
 
+    IntTuple it1 (INT_VALUE);
+    IntTuple it2;
+    it2 = std::move (it1);
+    VERIFY_TUPLE (it2);
+
+    // move assignment ill-formed for constant element types
+
+    NestedTuple nt1 (it2);
+    NestedTuple nt2;
+    nt2 = std::move (nt1);
+    VERIFY_TUPLE (std::get<0> (nt2));
+
+    PairTuple pt1 (LONG_VALUE, STRING_VALUE);
+    PairTuple pt2;
+    pt2 = std::move (pt1);
+    verify_tuple (pt2);
+
+    BigTuple bt1 (BOOL_VALUE, CHAR_VALUE, INT_VALUE, DBL_VALUE,
+                  PTR_VALUE, USER_VALUE);
+    BigTuple bt2;
+    bt2 = std::move (bt1);
+    verify_tuple (bt2);
+
+    const UserClass& uc = USER_VALUE;
+    UserTuple ut1 (uc);
+    UserTuple ut2;
     UserClass::reset_totals ();
-    UserTuple ut1, ut2; ut1 = ut2;
-    rw_assert (2 == UserClass::n_total_def_ctor_, __FILE__, __LINE__,
-               "tuple<UserClass>::tuple() called %d default ctors, "
-               "expected 2", UserClass::n_total_def_ctor_);
-    rw_assert (0 == UserClass::n_total_copy_ctor_, __FILE__, __LINE__,
-               "tuple<UserClass>::tuple() called %d copy ctors, "
-               "expected 0", UserClass::n_total_copy_ctor_);
-    rw_assert (1 == UserClass::n_total_op_assign_, __FILE__, __LINE__,
-               "tuple<UserClass>::tuple() called %d assign ops, "
-               "expected 1", UserClass::n_total_op_assign_);
+    ut2 = std::move (ut1);
+    verify_tuple (ut2, __LINE__, 0, 0, 1);
 }
 
 /**************************************************************************/
 
+// heterogenous tests do not apply to empty tuples so no tests required
+
+// UserClass does not currently contain any constructors or assignment
+// operators for heterogenous types so no user tuple tests performed
+
+#include <string>
+
+// need a string class with implicit conversion to type `const char*'
+struct String: public std::string
+{
+    String (): std::string () {}
+    String (const char* s): std::string (s) {}
+    operator const char* () const { return this->data (); }
+};
+
+typedef std::tuple<char>                CompatIntTuple;
+typedef std::tuple<unsigned, String>    CompatPairTuple;
+typedef std::tuple<int, int, short, float, char*,
+                   UserClass>           CompatBigTuple;
+
 static void
 test_hetero_copy_ctor ()
 {
     rw_info (0, __FILE__, __LINE__,
              "copy constructor (heterogenous tuples)");
 
-    const int i1 = 0; const char c = 'a'; const double d = 1.2;
-    void* const p = 0; const UserClass uc;
-    BigTuple bt1 (i1, c, i1, d, p, uc); _RWSTD_UNUSED (bt1);
-
-    const bool b = true; const int i2 = 'a';
-    BigTuple bt2 (b, i2, i1, d, p, uc); _RWSTD_UNUSED (bt2);
-
-    const float f = 1.2;
-    BigTuple bt3 (b, c, i1, f, p, uc); _RWSTD_UNUSED (bt3);
-
-    //UserTuple
+    const CompatIntTuple ct1 (INT_VALUE);
+    IntTuple it (ct1);
+    VERIFY_TUPLE (it);
+
+    CompatPairTuple ct2 (LONG_VALUE, STRING_VALUE);
+    PairTuple pt (ct2);
+    verify_tuple (pt);
+
+    const CompatBigTuple ct3 (BOOL_VALUE, CHAR_VALUE, INT_VALUE,
+        DBL_VALUE, (char*) PTR_VALUE, USER_VALUE);
+    BigTuple bt (ct3);
+    verify_tuple (bt);
 }
 
 /**************************************************************************/
@@ -284,14 +455,18 @@
     rw_info (0, __FILE__, __LINE__,
              "move constructor (heterogenous tuples)");
 
-    //EmptyTuple
-    //IntTuple
-    //ConstIntTuple;
-    //PairTuple
-    //NestedTuple
-
-    //UserTuple
-    // BigTuple
+    CompatIntTuple ct1 (INT_VALUE);
+    IntTuple it (std::move (ct1));
+    VERIFY_TUPLE (it);
+
+    CompatPairTuple ct2 (LONG_VALUE, STRING_VALUE);
+    PairTuple pt (std::move (ct2));
+    verify_tuple (pt);
+
+    CompatBigTuple ct3 (BOOL_VALUE, CHAR_VALUE, INT_VALUE,
+        DBL_VALUE, (char*) PTR_VALUE, USER_VALUE);
+    BigTuple bt (std::move (ct3));
+    verify_tuple (bt);
 }
 
 /**************************************************************************/
@@ -301,15 +476,21 @@
 {
     rw_info (0, __FILE__, __LINE__,
              "copy assignment operator (heterogenous tuples)");
-
-    //EmptyTuple
-    //IntTuple
-    //ConstIntTuple;
-    //PairTuple
-    //NestedTuple
-
-    //UserTuple
-    // BigTuple
+    CompatIntTuple ct1 (INT_VALUE);
+    IntTuple it;
+    it = ct1;
+    VERIFY_TUPLE (it);
+
+    CompatPairTuple ct2 (LONG_VALUE, STRING_VALUE);
+    PairTuple pt;
+    pt = ct2;
+    verify_tuple (pt);
+
+    CompatBigTuple ct3 (BOOL_VALUE, CHAR_VALUE, INT_VALUE,
+        DBL_VALUE, (char*) PTR_VALUE, USER_VALUE);
+    BigTuple bt;
+    bt = ct3;
+    verify_tuple (bt);
 }
 
 /**************************************************************************/
@@ -320,14 +501,21 @@
     rw_info (0, __FILE__, __LINE__,
              "move assignment operator (heterogenous tuples)");
 
-    //EmptyTuple
-    //IntTuple
-    //ConstIntTuple;
-    //PairTuple
-    //NestedTuple
-
-    //UserTuple
-    // BigTuple
+    CompatIntTuple ct1 (INT_VALUE);
+    IntTuple it;
+    it = std::move (ct1);
+    VERIFY_TUPLE (it);
+
+    CompatPairTuple ct2 (LONG_VALUE, STRING_VALUE);
+    PairTuple pt;
+    pt = std::move (ct2);
+    verify_tuple (pt);
+
+    CompatBigTuple ct3 (BOOL_VALUE, CHAR_VALUE, INT_VALUE,
+        DBL_VALUE, (char*) PTR_VALUE, USER_VALUE);
+    BigTuple bt;
+    bt = std::move (ct3);
+    verify_tuple (bt);
 }
 
 /**************************************************************************/
@@ -345,10 +533,13 @@
 /**************************************************************************/
 
 static int
-run_test (int /*unused*/, char* /*unused*/ [])
+run_test (int /*argc*/, char* argv [])
 {
     test_default_ctor ();
 
+    ptr_val = argv [0];
+    user_val.data_.val_ = INT_VALUE;
+
     test_value_copy_ctor ();
     test_value_move_ctor ();
 
@@ -375,13 +566,13 @@
 #if defined (_RWSTD_NO_EXT_CXX_OX)
 
     rw_warn (0, 0, __LINE__,
-			 "test disabled because _RWSTD_NO_EXT_CXX_0X is defined");
+             "test disabled because _RWSTD_NO_EXT_CXX_0X is defined");
 
 #elif defined (_RWSTD_NO_RVALUE_REFERENCES)
 
     rw_warn (0, 0, __LINE__,
-			 "test disabled because _RWSTD_NO_RVALUE_REFERENCES is "
-			 "defined");
+             "test disabled because _RWSTD_NO_RVALUE_REFERENCES is "
+             "defined");
 
 #endif
 

Modified: stdcxx/branches/4.3.x/tests/utilities/20.tuple.creation.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/utilities/20.tuple.creation.cpp?rev=675044&r1=675043&r2=675044&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/utilities/20.tuple.creation.cpp (original)
+++ stdcxx/branches/4.3.x/tests/utilities/20.tuple.creation.cpp Tue Jul  8 16:13:36 2008
@@ -63,11 +63,23 @@
 
 /**************************************************************************/
 
+#include <cstring>
+
 static void
 test_tie ()
 {
     rw_info (0, __FILE__, __LINE__, "tie");
 
+    int i = 0; double d = 0.0; const char* s = 0;
+    std::tie (i, std::ignore, s)
+        = std::make_tuple (256, 3.14159, "string");
+
+    rw_assert (i == 256, __FILE__, __LINE__,
+               "i == 256, got false, expected true");
+    rw_assert (d == 0.0, __FILE__, __LINE__,
+               "d == 0.0, got false, expected true");
+    rw_assert (0 == std::strcmp (s, "string"), __FILE__, __LINE__,
+               "s == \"string\", got false, expected true");
 }
 
 /**************************************************************************/

Modified: stdcxx/branches/4.3.x/tests/utilities/20.tuple.h
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/utilities/20.tuple.h?rev=675044&r1=675043&r2=675044&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/utilities/20.tuple.h (original)
+++ stdcxx/branches/4.3.x/tests/utilities/20.tuple.h Tue Jul  8 16:13:36 2008
@@ -36,22 +36,22 @@
 
 // various tuple types for test purposes
 
-typedef std::tuple < >                      EmptyTuple;
+typedef std::tuple <>                       EmptyTuple;
 
-typedef std::tuple < int >                  IntTuple;
-typedef std::tuple < const int >            ConstIntTuple;
-typedef std::tuple < int& >                 IntRefTuple;
+typedef std::tuple <int>                    IntTuple;
+typedef std::tuple <const int>              ConstIntTuple;
+typedef std::tuple <int&>                   IntRefTuple;
 
-typedef std::tuple < std::tuple < int > >   NestedTuple;
+typedef std::tuple <IntTuple>               NestedTuple;
 
-typedef std::tuple < long, const char* >    PairTuple;
+typedef std::tuple <long, const char*>      PairTuple;
 
-typedef std::tuple < UserClass >            UserTuple;
+typedef std::tuple <UserClass>              UserTuple;
 
-#define BigList      bool, char, int, double, void*, UserClass
-#define BigListSize  6
+#define BIG_TYPES   bool, char, int, double, void*, UserClass
+#define BIG_SIZE    6
 
-typedef std::tuple < BigList >              BigTuple;
+typedef std::tuple <BIG_TYPES>              BigTuple;
 
 
 #endif   // define RW_20_TUPLE_H_INCLUDED

Modified: stdcxx/branches/4.3.x/tests/utilities/20.tuple.helpers.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/utilities/20.tuple.helpers.cpp?rev=675044&r1=675043&r2=675044&view=diff
==============================================================================
--- stdcxx/branches/4.3.x/tests/utilities/20.tuple.helpers.cpp (original)
+++ stdcxx/branches/4.3.x/tests/utilities/20.tuple.helpers.cpp Tue Jul  8 16:13:36 2008
@@ -58,7 +58,7 @@
 
     TEST (PairTuple, 2);
 
-    TEST (BigTuple, BigListSize);
+    TEST (BigTuple, BIG_SIZE);
 }
 
 /**************************************************************************/



Mime
View raw message