Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2006-01-25 13:32:15


"Michael Goldshteyn" <mgoldshteyn_at_[hidden]> wrote

> Well, a one or two line comment in its header file (implicit_cast.hpp), at the
> very least, describing what it does wouldn't be too much to ask, in my
> opinion.

Seriously Its best to leave implicit_cast alone. The reason its not documented
is because if it was bad things would happen. Its like those what were they -
japanese pictures ? where the artist deliberately made one mistake. Without that
everything in the boost distro would be perfect and thats asking for trouble.
Thats why its seriously
best to leave it alone.

If any one wants to know what it does, I have knocked this slice of code
together to explain that it actually does nothing at all..

#include <boost/implicit_cast.hpp>

template <typename T>
struct value_typeA{
    T val;
    template <typename T1>
    explicit value_typeA( T1 const & t) : val((t)){}
};

template <typename T>
struct value_typeB{
    T val;
    template <typename T1>
    explicit value_typeB( T1 const & t) : val(boost::implicit_cast<T>(t)){}
};

int main()
{
    value_typeA<double> vA0(1);
    value_typeA<value_typeA<double> >vA1(vA0);
    value_typeA<value_typeA<double> >vA2(1);

    value_typeB<double> vB0(1);
    value_typeB<value_typeB<double> >vB1(vB0);
    value_typeB<value_typeB<double> >vB2(1);
}

regards
Andy Little


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