Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-03-01 10:31:18


On Friday 01 March 2002 10:16 am, you wrote:
> > template<typename T, size_t sz, size_t align>
> > struct member {
> > typedef typename ct_if<sizeof(T) <= sz && sizeof(U) <= align,
>
> What is 'U'?

My typo :(. It was supposed to be T.

> > T,
> > char>::type type;
> > };
> >
> > template<size_t sz, size_t align>
> > union force_align {
>
> What are 'sz' and 'align'?

The size and alignment of the type for which we want an alignment type. E.g.,
if we need to create aligned storage for std::string, we could use:

union std_string_raw_storage {
  force_align<sizeof(std::string), alignment_of<std::string>::value>::type
align1;
  
  char buffer[sizeof(std::string)];
};

        Doug


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