From dev-return-7791-apmail-stdcxx-dev-archive=stdcxx.apache.org@stdcxx.apache.org Fri Jun 06 23:17:28 2008 Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 12927 invoked from network); 6 Jun 2008 23:17:28 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Jun 2008 23:17:28 -0000 Received: (qmail 11417 invoked by uid 500); 6 Jun 2008 23:17:31 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 11352 invoked by uid 500); 6 Jun 2008 23:17:30 -0000 Mailing-List: contact dev-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 dev@stdcxx.apache.org Received: (qmail 11341 invoked by uid 99); 6 Jun 2008 23:17:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jun 2008 16:17:30 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [208.30.140.160] (HELO moroha.roguewave.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Jun 2008 23:16:34 +0000 Received: from exchmail01.Blue.Roguewave.Com (exchmail01.blue.roguewave.com [10.22.129.22]) by moroha.roguewave.com (8.13.6/8.13.6) with ESMTP id m56NGt04014827 for ; Fri, 6 Jun 2008 23:16:55 GMT X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: svn commit: r664141 - in /stdcxx/branches/4.3.x: include/type_traits tests/utilities/20.meta.help.cpp Date: Fri, 6 Jun 2008 17:16:51 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: svn commit: r664141 - in /stdcxx/branches/4.3.x: include/type_traits tests/utilities/20.meta.help.cpp Thread-Index: AcjIHrWnciqSFGmARXCNh2nnQz1mdgADHYXw References: <20080606214417.CB5282388A2A@eris.apache.org> From: "Eric Lemings" To: X-Virus-Checked: Checked by ClamAV on apache.org =20 I was wondering if it wouldn't make more sense to move just the integral_constant class template to its own header? If I just need that class template, I wouldn't want to have to pull in all the other type traits as well. Maybe under include/rw/_integral_constant.h? Brad. > -----Original Message----- > From: vitek@apache.org [mailto:vitek@apache.org]=20 > Sent: Friday, June 06, 2008 3:44 PM > To: commits@stdcxx.apache.org > Subject: svn commit: r664141 - in /stdcxx/branches/4.3.x:=20 > include/type_traits tests/utilities/20.meta.help.cpp >=20 > Author: vitek > Date: Fri Jun 6 14:44:17 2008 > New Revision: 664141 >=20 > URL: http://svn.apache.org/viewvc?rev=3D664141&view=3Drev > Log: > 2008-06-06 Travis Vitek >=20 > STDCXX-917 > * include/type_traits: Add type_traits header that > includes integral_contstant<> implementation. > * tests/utilities/20.meta.help.cpp: Add new test. > =09 >=20 > Added: > stdcxx/branches/4.3.x/include/type_traits (with props) > stdcxx/branches/4.3.x/tests/utilities/20.meta.help.cpp =20 > (with props) >=20 > Added: stdcxx/branches/4.3.x/include/type_traits > URL:=20 > http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/include/typ > e_traits?rev=3D664141&view=3Dauto > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- stdcxx/branches/4.3.x/include/type_traits (added) > +++ stdcxx/branches/4.3.x/include/type_traits Fri Jun 6 14:44:17 2008 > @@ -0,0 +1,86 @@ > + // -*- C++ -*- > +/************************************************************ > *************** > + * > + * type_traits - definition of type_traits types > + * > + * $Id$ > + * > +=20 > ************************************************************** > ************* > + * > + * Licensed to the Apache Software Foundation (ASF) under=20 > one or more > + * contributor license agreements. See the NOTICE file=20 > distributed > + * with this work for additional information regarding =20 > copyright > + * ownership. The ASF licenses this file to you under =20 > the Apache > + * License, Version 2.0 (the "License"); you may not use =20 > this file > + * except in compliance with the License. You may obtain =20 > a copy of > + * the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in=20 > writing, software > + * distributed under the License is distributed on an "AS=20 > IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either =20 > express or > + * implied. See the License for the specific language =20 > governing > + * permissions and limitations under the License. > + * > + * Copyright 2008 Rogue Wave Software, Inc. > + *=20 > +=20 > ************************************************************** > ************/ > + > +#ifndef _RWSTD_TYPE_TRAITS_INCLUDED > +#define _RWSTD_TYPE_TRAITS_INCLUDED > + > +#include > + > +#ifndef _RWSTD_NO_EXT_CXX_0X > + > +_RWSTD_NAMESPACE (std) { > + > +/** > + * The class template integral_constant and its associated typedefs > + * true_type and false_type are used as base classes to define the > + * interface for various type traits. > + */ > +template > +struct integral_constant > +{ > + /** > + * Describes the type of this integral_constant. > + */ > + typedef integral_constant<_TypeT,_Value> type; > + > + /** > + * Describes the type of the value defined by this=20 > integral_constant. > + */ > + typedef _TypeT value_type; > + > + /** > + * The actual integral constant value. > + */ > + static const _TypeT value =3D _Value; > +}; > + > +#ifndef _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION > + > +template > +const _TypeT integral_constant<_TypeT, _Value>::value; > + > +#endif // _RWSTD_NO_STATIC_CONST_MEMBER_DEFINITION > + > +/** > + * Convenience typedef that is intended to be used as a base class > + * for boolean type traits that are true. > + */ > +typedef integral_constant true_type; > + > +/** > + * Convenience typedef that is intended to be used as a base class > + * for boolean type traits that are false. > + */ > +typedef integral_constant false_type; > + > +} // namespace std > + > +#endif // _RWSTD_NO_EXT_CXX_0X > + > +#endif // _RWSTD_TYPE_TRAITS_INCLUDED >=20 > Propchange: stdcxx/branches/4.3.x/include/type_traits > -------------------------------------------------------------- > ---------------- > svn:eol-style =3D native >=20 > Propchange: stdcxx/branches/4.3.x/include/type_traits > -------------------------------------------------------------- > ---------------- > svn:keywords =3D Id >=20 > Added: stdcxx/branches/4.3.x/tests/utilities/20.meta.help.cpp > URL:=20 > http://svn.apache.org/viewvc/stdcxx/branches/4.3.x/tests/utili > ties/20.meta.help.cpp?rev=3D664141&view=3Dauto > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- stdcxx/branches/4.3.x/tests/utilities/20.meta.help.cpp (added) > +++ stdcxx/branches/4.3.x/tests/utilities/20.meta.help.cpp=20 > Fri Jun 6 14:44:17 2008 > @@ -0,0 +1,256 @@ > +// -*- C++ -*- > +/************************************************************ > *************** > + * > + * 20.meta.help.cpp - test exercising tr.meta.help > + * > + * $Id$ > + * > +=20 > ************************************************************** > ************* > + * > + * Licensed to the Apache Software Foundation (ASF) under=20 > one or more > + * contributor license agreements. See the NOTICE file=20 > distributed > + * with this work for additional information regarding =20 > copyright > + * ownership. The ASF licenses this file to you under =20 > the Apache > + * License, Version 2.0 (the "License"); you may not use =20 > this file > + * except in compliance with the License. You may obtain =20 > a copy of > + * the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in=20 > writing, software > + * distributed under the License is distributed on an "AS=20 > IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either =20 > express or > + * implied. See the License for the specific language =20 > governing > + * permissions and limitations under the License. > + * > + * Copyright 1999-2008 Rogue Wave Software, Inc. > + * > +=20 > ************************************************************** > ************/ > + > +#include > + > +#include > + > +// compile out all test code if extensions disabled > +#ifndef _RWSTD_NO_EXT_CXX_0X > + > +/************************************************************ > **************/ > + > +template > +bool test_is_same_type (T, U) > +{ > + return 0; > +} > + > +template > +bool test_is_same_type (T, T) > +{ > + return 1; > +} > + > +template > +bool test_is_const (T&) > +{ > + return 0; > +} > + > +template > +bool test_is_const (const T&) > +{ > + return 1; > +} > + > +template > +struct test_is_same > +{ > + enum { value =3D 0 }; > +}; > + > +template > +struct test_is_same > +{ > + enum { value =3D 1 }; > +}; > + > +enum enum_t { > + E_a, E_b, E_c > +}; > + > +/************************************************************ > **************/ > + > +template > +void test_integral_constant(const char* name, const char* value) > +{ > + typedef std::integral_constant > + integral_constant_type; > + > + // verify the type of value is the same as Type > + const bool a =3D > + test_is_same_type (integral_constant_type::value, Type ()); > + rw_assert (a, 0, __LINE__, > + "integral_constant<%s, %s>::value is%{?}n't%{;} " > + "of type %s", name, value, !a, name); > + > + // verify the value is as expected > + const bool b =3D > + integral_constant_type::value =3D=3D Value; > + rw_assert (b, 0, __LINE__, > + "integral_constant<%s, %s>::value is%{?}n't%{;} " > + "equal to %s", name, value, !b, value); > + > + // verify that the value is const > + const bool d =3D > + test_is_const (std::integral_constant::value); > + rw_assert (d, 0, __LINE__, > + "integral_constant<%s, %s>::value is%{?}n't%{;} " > + "a constant", name, value, !d); > + > + // verify that the type typedef is correct > + const bool e =3D > + test_is_same<_TYPENAME integral_constant_type::type, > + integral_constant_type>::value; > + rw_assert (e, 0, __LINE__, > + "integral_constant<%s, %s>::type is%{?}n't%{;} " > + "same as integral_constant<%s, %s>", > + name, value, !e, name, value); > + > + // note: compiler should never allow an instantiation of > + // integral_constant if T is not an integral type. > +} > + > +template > +void test_required_type (const char* name, const char* value) > +{ > + typedef Type integral_constant_type; > + > + // verify the type of the type typedef > + const bool a =3D > + test_is_same<_TYPENAME=20 > integral_constant_type::value_type, bool>::value; > + rw_assert (a, 0, __LINE__, > + "%s::value_type is%{?}n't%{;} same as bool", > + name, !a); > + > + // verify the value is as expected > + const bool b =3D > + integral_constant_type::value =3D=3D Value; > + rw_assert (b, 0, __LINE__, > + "%s::value is%{?}n't%{;} equal to %s", > + name, !b, value); > + > + // verify that Type is same as integral_constant > + const bool c =3D > + test_is_same,=20 > Type>::value; > + rw_assert (c, 0, __LINE__, > + "%s is%{?}n't%{;} of type=20 > integral_constant", > + name, !c, value); > + > + test_integral_constant<_TYPENAME=20 > integral_constant_type::value_type, > + Value>("bool", value); > +} > + > +/************************************************************ > **************/ > + > +static int run_test (int, char*[]) > +{ > +#define TEST_INTEGRAL_CONSTANT(Type,Value) \ > + test_integral_constant(#Type,#Value) > + > + TEST_INTEGRAL_CONSTANT (bool, true); > + TEST_INTEGRAL_CONSTANT (bool, false); > + > + TEST_INTEGRAL_CONSTANT (char, '\0'); > + TEST_INTEGRAL_CONSTANT (char, _RWSTD_CHAR_MIN); > + TEST_INTEGRAL_CONSTANT (char, _RWSTD_CHAR_MAX); > + > +#ifndef _RWSTD_NO_WCHAR_T > + TEST_INTEGRAL_CONSTANT (wchar_t, L'\0'); > + TEST_INTEGRAL_CONSTANT (wchar_t, _RWSTD_WCHAR_MIN); > + TEST_INTEGRAL_CONSTANT (wchar_t, _RWSTD_WCHAR_MAX); > +#endif // _RWSTD_NO_WCHAR_T > + > + TEST_INTEGRAL_CONSTANT (signed char, 0); > + TEST_INTEGRAL_CONSTANT (signed char, _RWSTD_SCHAR_MIN); > + TEST_INTEGRAL_CONSTANT (signed char, _RWSTD_SCHAR_MAX); > + > + TEST_INTEGRAL_CONSTANT (signed short, 0); > + TEST_INTEGRAL_CONSTANT (signed short, _RWSTD_SHRT_MIN); > + TEST_INTEGRAL_CONSTANT (signed short, _RWSTD_SHRT_MAX); > + > + TEST_INTEGRAL_CONSTANT (signed int, 0); > + TEST_INTEGRAL_CONSTANT (signed int, _RWSTD_INT_MIN); > + TEST_INTEGRAL_CONSTANT (signed int, _RWSTD_INT_MAX); > + > + TEST_INTEGRAL_CONSTANT (signed long, 0); > + TEST_INTEGRAL_CONSTANT (signed long, _RWSTD_LONG_MIN); > + TEST_INTEGRAL_CONSTANT (signed long, _RWSTD_LONG_MAX); > + > +#ifndef _RWSTD_NO_LONG_LONG > + TEST_INTEGRAL_CONSTANT (signed long long, 0); > + TEST_INTEGRAL_CONSTANT (signed long long, _RWSTD_LLONG_MIN); > + TEST_INTEGRAL_CONSTANT (signed long long, _RWSTD_LLONG_MAX); > +#endif // _RWSTD_NO_LONG_LONG > + > + TEST_INTEGRAL_CONSTANT (unsigned char, 1); > + TEST_INTEGRAL_CONSTANT (unsigned char, _RWSTD_UCHAR_MIN); > + TEST_INTEGRAL_CONSTANT (unsigned char, _RWSTD_UCHAR_MAX); > + > + TEST_INTEGRAL_CONSTANT (unsigned short, 1); > + TEST_INTEGRAL_CONSTANT (unsigned short, _RWSTD_USHRT_MIN); > + TEST_INTEGRAL_CONSTANT (unsigned short, _RWSTD_USHRT_MAX); > + > + TEST_INTEGRAL_CONSTANT (unsigned int, 1); > + TEST_INTEGRAL_CONSTANT (unsigned int, _RWSTD_UINT_MIN); > + TEST_INTEGRAL_CONSTANT (unsigned int, _RWSTD_UINT_MAX); > + > + TEST_INTEGRAL_CONSTANT (unsigned long, 1); > + TEST_INTEGRAL_CONSTANT (unsigned long, _RWSTD_UINT_MIN); > + TEST_INTEGRAL_CONSTANT (unsigned long, _RWSTD_UINT_MAX); > + > +#ifndef _RWSTD_NO_LONG_LONG > + TEST_INTEGRAL_CONSTANT (unsigned long long, 1); > + TEST_INTEGRAL_CONSTANT (unsigned long long, _RWSTD_ULLONG_MIN); > + TEST_INTEGRAL_CONSTANT (unsigned long long, _RWSTD_ULLONG_MAX); > +#endif // _RWSTD_NO_LONG_LONG > + > + TEST_INTEGRAL_CONSTANT (enum_t, E_a); > + TEST_INTEGRAL_CONSTANT (enum_t, E_b); > + TEST_INTEGRAL_CONSTANT (enum_t, E_c); > + > +#ifdef _ILL_FORMED > + TEST_INTEGRAL_CONSTANT (float, 1.f); > +#endif // _ILL_FORMED > + > +#define TEST_REQUIRED_TYPE(Type,Value) \ > + test_required_type(#Type, #Value); > + > + TEST_REQUIRED_TYPE (std::true_type , true); > + TEST_REQUIRED_TYPE (std::false_type, false); > + > + return 0; > +} > + > +/************************************************************ > **************/ > + > +#else // _RWSTD_NO_EXT_CXX_0X > + > +/************************************************************ > **************/ > + > +static int run_test (int, char*[]) > +{ > + rw_warn (0, 0, __LINE__, > + "test disabled because _RWSTD_NO_EXT_CXX_0X is=20 > defined"); > + return 0; > +} > + > +#endif // !_RWSTD_NO_EXT_CXX_0X > + > +/************************************************************ > **************/ > + > +int main (int argc, char *argv[]) > +{ > + return rw_test (argc, argv, __FILE__, > + "tr.meta.help", > + 0 /* no comment */, > + run_test, > + 0); > +} >=20 > Propchange: stdcxx/branches/4.3.x/tests/utilities/20.meta.help.cpp > -------------------------------------------------------------- > ---------------- > svn:eol-style =3D native >=20 > Propchange: stdcxx/branches/4.3.x/tests/utilities/20.meta.help.cpp > -------------------------------------------------------------- > ---------------- > svn:keywords =3D Id >=20 >=20 >=20