Boost logo

Boost :

From: John Maddock (John_Maddock_at_[hidden])
Date: 2000-07-31 06:55:05

Hi all,

I've created a cvs-branch called "conversion" with two additional classes
and one changed class , the tests have also been refactored and updated,
the code is in the vault under type_traits for those without cvs access.

        true if T is convertible to U, based upon the code in in the vault. I've also copied the copyright notice from
that file over into type_traits.hpp - Jeremy is this OK with you?

        updated to use is_convertible<T,int>::value to screen out enum's;
this change filters through to compressed_pair which can now be used with
enum types.

        The alignment of some arbitary type T; last time I tried this Steve
Cleary shot me down in flames (rightly as it wasn't portable), hopefully
this version is OK!

The implementation of alignment_of is quite simple:

template <class T>
class alignment_of
   struct padded
      char c;
      T t;
   static const unsigned value = sizeof(padded) - sizeof(T);
// references have to be treated specially, assume
// that a reference is just a special pointer:
template <class T>
class alignment_of<T&>
   static const unsigned value = alignment_of<T*>::value;

This is guarenteed to produce a multiple of the actual alignment of the
type - if the compiler does not add gratuitous amounts of padding to it's
struct's then it will return exactly the alignment value (and so far all
the compiler that I have tested do so).

Finally, there have been problems with my test code not compiling with
MWCW, can someone please test these modified versions? If you are able to
fix any problems then go ahead and make the changes to the cvs-branch.

Thanks, in advance,

- John.

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