
On Dec 2, 2004, at 9:46 PM, Matt Austern wrote:
On Thu, 2 Dec 2004 21:02:10 -0500, Howard Hinnant <hinnant@twcny.rr.com> wrote:
Metrowerks::has_trivial_copy_ctor<T>::value
for a year or two now (depending on platform). Some of the STL containers use this information for optimizations. The implementation of this trait is tied to the Metrowerks compiler in a non-standard-C++ fashion (e.g. a compiler intrinsic).
This is probably getting to be more standards-related than boost-related, but... Assuming it isn't proprietary information, it would be useful if you could say a little bit about what your intrinsic looks like. As you may know, the core people, especially EDG, would like to see those sorts of intrinsics standardized. Everyone is going to have to implement some kind of interface that makes type traits implementable, and the EDG people figure that everyone might as well all implement the same thing.
No problem. I have my doubts about needing to standardize at the language level, that's what std::libs are for: We write non-portable code so you don't have to. (that's my motto) :-) Although a de-facto, unofficial standard would certainly be convenient for us vendors. But here is a copy/paste: template <class T> struct class_has_trivial_copy_ctor { #if __MWERKS__ >= 0x3100 static const bool value = __builtin_trivial_members(T) & 0x4; #else static const bool value = false; // hook #endif }; Notes: class_has_trivial_copy_ctor is not a client level interface, has_trivial_copy_ctor is. At the class_has_trivial_copy_ctor level, T is guaranteed to be a struct or a class (not a union, scalar, reference, array, void or function) (fwiw). -Howard