Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2006-06-28 10:22:37


On Wed, 28 Jun 2006 15:31:07 +0200, "Philippe Vaucher"
<philippe.vaucher_at_[hidden]> wrote:

>Hum, actually it might be better to do it like :
>
>template <class Arr>
>struct count_of
>{
> BOOST_STATIC_ASSERT(boost::is_array<Arr>::value);
> enum { value = sizeof(Arr)/sizeof(Arr[0]) };
>};
>
>Sorry if I missed a point, joined late in the discussion :)

The whole machinery is supposed to work with expressions, not
type-ids, as you may see from my examples. And of course Arr[0] is not
a valid type-id anyway.

As you can see, though we have is_array I've basically to reimplement
it. I've raised the point in the past that either is_array and other
things such as is_convertible should work on expressions too, because
this way they would most closely follow the language rules, and
because you can easily implement the type-based versions in terms of
the expression based ones but not viceversa. Unfortunately (or not,
I'll leave it to you to decide) I've been totally ignored. At least,
the second, IMHO compelling argument of implementability "in terms
of", is completely omitted in the type_traits proposal.

--Gennaro.


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