Boost logo

Boost :

From: shunsuke (pstade.mb_at_[hidden])
Date: 2007-05-14 05:26:24


Christian Holmquist wrote:
>> It must be useful.
>> It could be more useful if it supports 'is_std_pair' and 'is_std_vector'
> etc.
>> Also, <std_pair_fwd.hpp> and <std_vector_fwd.hpp> etc could be useful.
>
> My first attempt was implemented this way, by simply forward declaring std
> containers:
>
> namespace std
> {
> template<class T, class Alloc> class vector;
> }
>
> template<class T, class Alloc>
> struct is_container< std::vector<T, Alloc> > : public boost::true_type
> {
> typedef sequence_tag container_category;
> };
>
>
>
> This of course didn't scale very well, since it required is_container<> to
> be manually specialized for every container class.
> I needed something that worked automatically, so I decided for the following
> implementation..
> Do you think it would be better to forward declare classes instead? (i.e.,
> multi_index, ptr_container, array etc..)

The has_xxx way may return a superset. For example,
'boost::iterator_range' might be wrongly identified as container,
and a program might be ill-formed.
So it may have little choice but to return a subset, IMO.

IIRC, a forward declaration of standard container is, strictly speaking, not allowed.
Also, vector is allowed to have extra template parameters.
A portable layer to bell a cat can be valuable.

Regards,

-- 
Shunsuke Sogame

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