Return-Path: Delivered-To: apmail-stdcxx-commits-archive@www.apache.org Received: (qmail 45395 invoked from network); 19 Jun 2008 22:10:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Jun 2008 22:10:04 -0000 Received: (qmail 52419 invoked by uid 500); 19 Jun 2008 22:10:06 -0000 Delivered-To: apmail-stdcxx-commits-archive@stdcxx.apache.org Received: (qmail 52394 invoked by uid 500); 19 Jun 2008 22:10:06 -0000 Mailing-List: contact commits-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list commits@stdcxx.apache.org Received: (qmail 52385 invoked by uid 99); 19 Jun 2008 22:10:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jun 2008 15:10:06 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 19 Jun 2008 22:09:25 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 09CE223889C2; Thu, 19 Jun 2008 15:09:14 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r669723 - in /stdcxx/branches/4.3.x: include/rw/_meta_cv.h include/rw/_tuple.h include/tuple tests/utilities/20.tuple.elem.cpp Date: Thu, 19 Jun 2008 22:09:13 -0000 To: commits@stdcxx.apache.org From: elemings@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080619220914.09CE223889C2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: elemings Date: Thu Jun 19 15:09:13 2008 New Revision: 669723 URL: http://svn.apache.org/viewvc?rev=669723&view=rev Log: 2008-06-19 Eric Lemings STDCXX-958 * include/rw/_meta_cv.h: Include to define __rw_is_reference trait. * include/rw/_tuple.h (__get): Add new accessors to allow access to head element value. Accessors are public but intended (and undocumented) for internal use only. * include/tuple (tuple_element): Added internal get() helpers. (get): Implemented and documented. * tests/utilities/20.tuple.elem.cpp: Added framework for new (and incomplete) test for tuple element accessors. Added: stdcxx/branches/4.3.x/tests/utilities/20.tuple.elem.cpp Modified: stdcxx/branches/4.3.x/include/rw/_meta_cv.h stdcxx/branches/4.3.x/include/rw/_tuple.h stdcxx/branches/4.3.x/include/tuple Modified: stdcxx/branches/4.3.x/include/rw/_meta_cv.h URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/rw/_meta_cv.h?rev=669723&r1=669722&r2=669723&view=diff ============================================================================== --- stdcxx/branches/4.3.x/include/rw/_meta_cv.h (original) +++ stdcxx/branches/4.3.x/include/rw/_meta_cv.h Thu Jun 19 15:09:13 2008 @@ -32,6 +32,7 @@ #include #include +#include _RWSTD_NAMESPACE (__rw) { 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=669723&r1=669722&r2=669723&view=diff ============================================================================== --- stdcxx/branches/4.3.x/include/rw/_tuple.h (original) +++ stdcxx/branches/4.3.x/include/rw/_tuple.h Thu Jun 19 15:09:13 2008 @@ -103,6 +103,9 @@ public: + _HeadT& __get () { return _C_head; } + const _HeadT& __get () const { return _C_head; } + /** * Construct tuple with default values. */ Modified: stdcxx/branches/4.3.x/include/tuple URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/tuple?rev=669723&r1=669722&r2=669723&view=diff ============================================================================== --- stdcxx/branches/4.3.x/include/tuple (original) +++ stdcxx/branches/4.3.x/include/tuple Thu Jun 19 15:09:13 2008 @@ -36,7 +36,10 @@ # error _RWSTD_NO_EXT_CXX_0X defined and C++0x header included # endif // defined _RWSTD_NO_EXT_CXX_0X +# include // for __rw_add_const # include // for __rw_integral_constant +# include // for __rw_add_lvalue_reference + # include # include @@ -129,7 +132,7 @@ * tuple_size<T>::value. If N is not in this range * or for any other arbitrary type, the program is ill-formed. * - * @tparam Index An integer constant. + * @tparam Index An integer constant indicating the Nth element type. * @tparam Types List of element types in the tuple. */ @@ -141,6 +144,27 @@ { /** The Nth element type of the tuple. */ typedef _Head type; + + + typedef tuple<_Head, _Tail...> _Tuple; + +# define _RWSTD_ADD_CONST(T) \ + _TYPENAME _RW::__rw_add_const::type +# define _RWSTD_ADD_LVAL_REF(T) \ + _TYPENAME _RW::__rw_add_lvalue_reference::type + + typedef _RWSTD_ADD_CONST (_Head) _Const; + typedef _RWSTD_ADD_LVAL_REF (_Head) _Ref; + typedef _RWSTD_ADD_LVAL_REF (_Const) _ConstRef; + +# undef _RWSTD_ADD_CONST +# undef _RWSTD_ADD_LVAL_REF + + static _Ref + __get (_Tuple& __tuple) { return __tuple.__get (); } + + static _ConstRef + __get (const _Tuple& __tuple) { return __tuple.__get (); } }; template @@ -153,13 +177,35 @@ // 20.3.1.5, element access: -template -_TYPENAME tuple_element<_Index, tuple<_Types...> >::type& -get (tuple<_Types...>&); - -template -_TYPENAME tuple_element<_Index, tuple<_Types...> >::type const& -get (const tuple<_Types...>&); +/** + * @function get + * + * Access Nth element value of a tuple. This function returns a + * cv-qualified value reference to the Nth element in a tuple \c T + * where 0 <= N < tuple_size<T>::value. If N is + * not in this range, the program is ill-formed. + * + * @tparam Index An integer constant indicating the Nth element type. + * @tparam Types List of element types in the tuple. + * @param tuple A tuple value. + * @return CV-qualified reference to the Nth element value of tuple. + */ + +template +_TYPENAME tuple_element<_Index, tuple<_Head, _Tail...> >::_Ref +get (tuple<_Head, _Tail...>& __tuple) +{ + typedef tuple_element<_Index, tuple<_Head, _Tail...> > _Tuple; + return _Tuple::__get (__tuple); +} + +template +_TYPENAME tuple_element<_Index, tuple<_Head, _Tail...> >::_ConstRef +get (const tuple<_Head, _Tail...>& __tuple) +{ + typedef tuple_element<_Index, tuple<_Head, _Tail...> > _Tuple; + return _Tuple::__get (__tuple); +} // 20.3.1.6, relational operators: Added: stdcxx/branches/4.3.x/tests/utilities/20.tuple.elem.cpp URL: http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/utilities/20.tuple.elem.cpp?rev=669723&view=auto ============================================================================== --- stdcxx/branches/4.3.x/tests/utilities/20.tuple.elem.cpp (added) +++ stdcxx/branches/4.3.x/tests/utilities/20.tuple.elem.cpp Thu Jun 19 15:09:13 2008 @@ -0,0 +1,75 @@ +/*************************************************************************** + * + * 20.tuple.elem.cpp - tests exercising tuple element accessors + * + * $Id$ + * + *************************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + * implied. See the License for the specific language governing + * permissions and limitations under the License. + * + * Copyright 2008 Rogue Wave Software. + * + **************************************************************************/ + +#include + +#include "20.tuple.h" + +/**************************************************************************/ + +#include + +static void +test_get () +{ + rw_info (0, __FILE__, __LINE__, "get"); + + IntTuple it (4); + rw_assert (std::get<0> (it) == 4, __FILE__, __LINE__, + "get<0> (it), got %d, expected 4", std::get<0> (it)); +} + +/**************************************************************************/ + +static void +test_const_get () +{ + rw_info (0, __FILE__, __LINE__, "get (const)"); + +} + +/**************************************************************************/ + +static int +run_test (int /*unused*/, char* /*unused*/ []) +{ + test_get (); + test_const_get (); + + return 0; +} + +/*extern*/ int +main (int argc, char* argv []) +{ + return rw_test (argc, argv, __FILE__, + "[tuple.elem]", + "20.3.1.5 Element access", + run_test, "", 0); +} +