Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2003-03-08 07:47:13


"David Abrahams" <dave_at_[hidden]> wrote in message
news:uzno6sp2p.fsf_at_boost-consulting.com...
> "Thorsten Ottosen" <nesotto_at_[hidden]> writes:
>
> > my code does not include <vector>, <list> or <map>, but it does need
> > <iterator>.
> >
> > Some of the functionality of the container_traits are shown here:
> >
> >
> > template< typename C >
> > bool is_container()
> > {
> > return boost::container_traits<C>::is_container();
> > }
>
> ...
>
> Yes, you can take an approach like this one, but it will cause false
> positives in some circumstances. If that's acceptable for your
> application, then it's a good answer.

I guess you're thinking about classes with eg. an iterator typedef.
Couldn't the procedure be improved a little by doing something
like

      template< typename C >
     true_t is_container( const C&, const typename C::iterator& =
      typename C::iterator(),
    const typename C::const_iterator& = typename C::const_iterator(),
    <more of the same here> );

That way we would reduce the likelyhood of false positives a lot. Or would
we?

regards

Thorsten


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