boost.png (6897 bytes) Home Libraries People FAQ More

PrevUpHomeNext

Support for Compiler Intrinsics

There are some traits that can not be implemented within the current C++ language: to make these traits "just work" with user defined types, some kind of additional help from the compiler is required. Currently (May 2005) MWCW 9 and Visual C++ 8 provide the necessary intrinsics, and other compilers will no doubt follow in due course.

The Following traits classes always need compiler support to do the right thing for all types (but all have safe fallback positions if this support is unavailable):

The following traits classes can't be portably implemented in the C++ language, although in practice, the implementations do in fact do the right thing on all the compilers we know about:

The following traits classes are dependent on one or more of the above:

The hooks for compiler-intrinsic support are defined in boost/type_traits/intrinsics.hpp, adding support for new compilers is simply a matter of defining one of more of the following macros:

Macros for Compiler Intrinsics

BOOST_IS_UNION(T) Should evaluate to true if T is a union type
BOOST_IS_POD(T) Should evaluate to true if T is a POD type
BOOST_IS_EMPTY(T) Should evaluate to true if T is an empty struct or union
BOOST_HAS_TRIVIAL_CONSTRUCTOR(T) Should evaluate to true if the default constructor for T is trivial (i.e. has no effect)
BOOST_HAS_TRIVIAL_COPY(T) Should evaluate to true if T has a trivial copy constructor (and can therefore be replaced by a call to memcpy)
BOOST_HAS_TRIVIAL_ASSIGN(T) Should evaluate to true if T has a trivial assignment operator (and can therefore be replaced by a call to memcpy)
BOOST_HAS_TRIVIAL_DESTRUCTOR(T) Should evaluate to true if T has a trivial destructor (i.e. ~T() has no effect)
BOOST_HAS_NOTHROW_CONSTRUCTOR(T) Should evaluate to true if T x; can not throw
BOOST_HAS_NOTHROW_COPY(T) Should evaluate to true if T(t) can not throw
BOOST_HAS_NOTHROW_ASSIGN(T) Should evaluate to true if T t, u; t = u can not throw
BOOST_HAS_VIRTUAL_DESTRUCTOR(T) Should evaluate to true T has a virtual destructor
Copyright © 2000, 2005 Adobe Systems Inc, David Abrahams, Steve Cleary, Beman Dawes, Aleksey Gurtovoy, Howard Hinnant, Jesse Jones, Mat Marcus, Itay Maman, John Maddock, Thorsten Ottosen, Robert Ramey and Jeremy Siek

PrevUpHomeNext