Boost logo

Boost :

From: Seweryn Habdank-Wojewódzki (shw_at_[hidden])
Date: 2007-09-23 17:51:49


Dears

There are two codes. The first is workig as it is specified in the
documentation, but the second not. Why there are problems with the second
code?

Regards.

// This code works perfectly

#include <boost/type_traits.hpp>
#include <boost/static_assert.hpp>
#include <boost/utility.hpp>

template <typename B, typename R>
class test
{
public:
    test ()
    {
        BOOST_STATIC_ASSERT((boost::is_base_of<B, R>::value));
    }
};

int main()
{
    test <int, int> t ();
}

// The code belo is not working

#include <boost/type_traits.hpp>
#include <boost/static_assert.hpp>
#include <boost/utility.hpp>

template <typename B>
class test
{
public:
    template <typename R>
    test (R const &)
    {
        BOOST_STATIC_ASSERT((boost::is_base_of<B, R>::value));
    }
};

int main()
{
    test <int> t (static_cast<int>(0));
}

-- 
|\/\/|   Seweryn Habdank-Wojewódzki
 \/\/ 

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