Boost logo

Boost :

From: John Maddock (jm_at_[hidden])
Date: 2003-01-25 06:48:52


> I think we must still answer the fundamental question: *why* we need
> is_convertible applied to a type instead of an expression? If you
> check convertibility it's because you want to convert something,
> right? Then what can you legally convert if not an expression? Given
> that, why not using the function templates I gave in my other posting?
> As you know (you are the one who suggested that solution for
> implicit_cast), with them access checking is made in the context of
> the function call expression, so we get rid of the problem completely.
> No?

There are all kind of useful uses for is_convertible that do not involve
converting anything as such, for example:

template <class I>
struct is_random_access_iterator
{
private:
   typedef typename std::iterator_traits<I>::iterator_category cat;
public:
   BOOST_STATIC_CONSTANT(bool, value = (::boost::is_convertible<cat*,
std::random_access_iterator_tag*>::value));
};

There are lots of other similar uses, particularly for concept checks and
the like...

John Maddock
http://ourworld.compuserve.com/homepages/john_maddock/index.htm


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