Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2003-02-19 13:10:58


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));
    }

-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