Boost logo

Boost :

From: nee Spangenberg (dsp_at_[hidden])
Date: 2003-12-03 08:22:52


AlisdairM schrieb:

> The following seems such an obvious utility, I was surprised I could not
> find it in the boost distribution. Could someone point me to the
> equivalent if I am missing it. Alternatively, is this worth cleaning up
> for a submission?

I remember that it was part of boost, I think in Version 1.28 or so. I also
wondered loudly (but obviously not loud enough) about its missing in
newer versions some month ago. The functions named sizer with signature

  template <typename T, int sz>
  inline char (&sizer(T (&)[sz]))[sz];

was inside array_traits.hpp and allowed compile-time evaluation of
fixed array sizes, while the traits-class array_traits provided the static
size function which provided run-time evaluation via partial specialization
of the traits class. The implementation of

template <typename T, std::size_t sz>
struct array_traits<T[sz]> ;

and

template <typename T, std::size_t sz>
struct array_traits<T const[sz]>;

was:

...
size_type size(T (&)[sz]) { return sz; }
...

similar to your proposal.

Interestingly today's boost version has moved array_traits.hpp into
the type_traits subdirectory (that is ok), but replaced its implementation
by

#include "boost/type_traits/is_array.hpp"

This is also not so bad in the first place, but the fact, that is_array.hpp
does not **additionally** contain the original array_traits stuff, is somewhat
nasty.

Greetings from Bremen,

Daniel


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