Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2003-01-07 10:29:55


The types yes_type and no_type (or equivalent) - that is, two types which
are guaranteed to have different size - is used extensively for Boost type
traits, and also in some other libraries (iterator.hpp,
named_template_params.hpp, multi_array, Phyton and signals). Some places use
the type traits ones (<boost/type_traits/detail/yes_no_types.hpp>), other
define them themselves.

In the type traits docs (or any other docs I've found), these aren't
mentioned (and they are defined in the "detail"-directory, suggesting it's
an implementation detail). Yet, other libraries use them, as well. Perhaps
these should be documented, so they may be relied on, and other libraries
may avoid having to define them, themselves?

By the way, these are defined as char and double, respectively. Are these
required to have different size? I haven't found that guarantee in the C++
or C standard. Theoretically, you might have an architecture which operated
only on values of one size, so that char and double would have the same
size.

In that case, maybe something like this could be safer:

typedef char yes_type[1];
typedef char no_type[2];

Regards,

Terje


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk