Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2003-01-31 07:45:12


--- John Maddock <jm_at_[hidden]> wrote:
>
> > The technique I know relies on detecting whether the template argument
> > is *derived* from some policy, and that's doable with expressions.
> > That's why I asked you what was the exact technique you were using.
> > Also, if you have any (other) example where "convertibility of a type"
> > is needed I would be glad to see it, because this is IMHO a crucial
> > point.
>
> Yes, it's really a derived from test, so is_base_and_derived would do I
> guess. Which brings us back to things like:
>
> template <class I>
> struct is_bidirectional_iterator
> {
> private:
> typedef typename std::iterator_traits<I>::iterator_category cat;
> public:
> BOOST_STATIC_CONSTANT(bool, value = (::boost::is_convertible<cat*,
> std::bidirectional_iterator_tag*>::value));
> };

And I've already showed how to do this with expressions. With pointers you have
no problem at all: to see if T* "is convertible" to U* you see whether the
expression ((T*)(0)) is implictly convertible to U*.

> Perhaps my main argument is philosophical

Frankly, and with no offense intended, I think it's just clutching at straws
:-)

> I
> think that the current solution is well understood

Uh?? Well understood??

> and easy to use, and it
> *conceptually*

Conceptually? Or "formally"?

> fits in well with the other type traits. IMO a free function
> is more like a code snippet that a packaged solution: but that is very much
> a personal preference.

:-)

Genny.

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


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