|
Boost : |
From: Christian Holmquist (c.holmquist_at_[hidden])
Date: 2007-05-23 02:53:27
> 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.
Understood.
So, would a more correct implementation of is_container forward declare STL
containers in a portable way and specialize the traits class for each one?
I'm working with STLport and VC 7.1/8.0 so I can have the forward
declarations working for these, but I don't know about other stl
implementations.
Thanks a lot for your input.
On 14/05/07, shunsuke <pstade.mb_at_[hidden]> wrote:
>
> 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
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk