Boost logo

Boost :

From: Eric Friedman (ebf_at_[hidden])
Date: 2003-11-27 04:59:03

To all-

In the course of finalizing the documentation for Boost.Variant, I have
come across a snag in terms of directing the user how to specialize
several of the type traits templates.

Specifically, certain optimizations for variant<T1,...,TN> are enabled
only if boost::has_nothrow_copy and/or boost::has_nothrow_constructor
have 'true' results for some of variant's bounded types Ti.

As we all know, though, without support from the compiler, these type
traits by default have false results for any class or struct type. Thus
it will be very important for the user to be able to specialize these

It seems to me the standard form of such a specialization would look as

// file scope...
namespace boost {

   template <>
   struct has_nothrow_copy< myUDT >
     : mpl::true_


The problem I see here is this approach (needlessly) forces MPL upon the

I see two possible solutions to this problem:

  1) Provide a typedef of boost::mpl::true_ named boost::true_, or
     perhaps boost::tt_true to keep it Type Traits-specific. (I suppose
     we could do the same for false_.)

  2) Write some macro to facilitate specialization of Type Traits
     templates such as has_nothrow_copy, etc.

IMO, #1 is the only reasonable option. The question remains, however,
what to name the true/false types: true_? tt_true? something else?

I'd like to get this worked out quickly so as to avoid unnecessary
hassle for users of Boost.Variant. Feedback?


Boost list run by bdawes at, gregod at, cpdaniel at, john at