From dev-return-8214-apmail-stdcxx-dev-archive=stdcxx.apache.org@stdcxx.apache.org Fri Jul 18 16:21:03 2008 Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 85375 invoked from network); 18 Jul 2008 16:21:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jul 2008 16:21:03 -0000 Received: (qmail 65633 invoked by uid 500); 18 Jul 2008 16:21:03 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 65616 invoked by uid 500); 18 Jul 2008 16:21:02 -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 65605 invoked by uid 99); 18 Jul 2008 16:21:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Jul 2008 09:21:02 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.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, 18 Jul 2008 16:20:09 +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 m6IGIWCU029031 for ; Fri, 18 Jul 2008 16:18:32 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: fallback support for traits Date: Fri, 18 Jul 2008 10:18:21 -0600 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: fallback support for traits Thread-Index: AcjoPBoj50ZbM3joRG6euQZmLJ7b9wAq4KUg References: <487F8548.5030205@roguewave.com> <487F905A.9080404@roguewave.com> From: "Travis Vitek" To: X-Virus-Checked: Checked by ClamAV on apache.org We currently have the _RWSTD_TT_* macros (referred to below as _TT_ macros). The original intent was to define them to the compiler built-in for the named type trait. I.e., _RWSTD_TT_IS_POD(T) would expand to __is_pod(T) on those systems that supply the __is_pod() built-in. While porting the traits, I wrote code to augment the definition of several of these macros. For instance, on eccp-3.10, the __has_trivial_constructor() built-in evaluates to false for scalar types and arrays of such types, but it does correctly detect class types that have a trivial default constructor. So I do something like this for such a platform... template struct __has_trivial_ctor_impl { typedef typename __rw_remove_all_extents<_TypeT>::type _TypeU; enum { value =3D __rw_is_scalar<_TypeU>::value || _RWSTD_TT_HAS_TRIVIAL_CTOR(_TypeU) }; }; #undef _RWSTD_TT_HAS_TRIVIAL_CTOR #define _RWSTD_TT_HAS_TRIVIAL_CTOR(T) \ _RW::__rw_has_trivial_ctor_impl::value Now I have a macro that evaluates to true under the right conditions, but it isn't defined to be the same as one of the built-ins as originally intended. It was suggested that I not do this, and instead only define the macros to the built-ins that are provided. The problem is that I don't really see the macros as being very useful when they are not as accurate as they could be. Another issue is that in some cases, my fallback (which uses little or no compiler support) is more accurate than the provided trait. In these cases, I don't define the _TT_ macro, and I just use the fallback implementation. So now I'm ignoring the compiler support in some cases. The advantage of doing this is that I don't need to add a bunch of conditional code to the internal headers to avoid using broken built-ins. So, my question is, what is the right way? Should I always define the _TT_ macros to the native traits only, even if they're broken and then just work around the issues at the definition of the trait template? Is it acceptable to not define the _TT_ macro when the internal trait is available, but is broken? Travis