Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-02-19 15:31:38


David Abrahams <dave_at_[hidden]> writes:

> I'm in love with the new is_convertible; I can now detect "move-copy"
> types like auto_ptr! Could the old is_convertible do this?
>
>
> #include <boost/type_traits/is_convertible.hpp>
> #include <boost/static_assert.hpp>
> #include <memory>
>
> int main()
> {
> BOOST_STATIC_ASSERT(
> (boost::is_convertible<
> std::auto_ptr<int>, std::auto_ptr<int>
> >::value));
>
> BOOST_STATIC_ASSERT(
> (boost::is_convertible<
> std::auto_ptr<int>&, std::auto_ptr<int>
> >::value));
>
> BOOST_STATIC_ASSERT(
> (!boost::is_convertible<
> std::auto_ptr<int> const&, std::auto_ptr<int>
> >::value));
>
> BOOST_STATIC_ASSERT(
> (!boost::is_convertible<
> std::auto_ptr<int> const, std::auto_ptr<int>
> >::value));
> }

OK, I give up. This doesn't work for GCC. Does anybody have a clever
route to detecting types whose copy ctor have a non-const RHS? It's
fine to assume that an accessible copy ctor exists.

TIA,
Dave

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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