>From: "David Abrahams" <[EMAIL PROTECTED]> > Terje Slettebų <[EMAIL PROTECTED]> writes: > > > 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? > > Sure! Submit a patch (with docs) for the utility library.
Ok. Here's <boost/utility/yes_no_type.hpp>. I just used the file <boost/type_traits/detail/yes_no_type.hpp>, changed the include guard, moved it from boost::type_traits to boost namespace (is that ok? After all, the other components in utility.hpp is in the boost namespace, too), and changed the definition of the types to the ones suggested (using reference to array). It might be a good idea for those who have libraries that use them (especially if they use char and double for the types), to use the new ones, to ensure that it works on all platforms. I'll write suggested docs, as well. > > 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]; > > They have to be references or you can't return them ;-) Right. Changed now. Regards, Terje
yes_no_type.hpp
Description: Binary data
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost