Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2002-11-21 19:15:21

The boost cast library used to have an implicit_cast template, which
was stricken because it didn't work and was wrong. However, since
then, I've often found that I needed such a beast. Usually this need
arises when I want to induce a conversion to something that might be a
built-in type, for which constructor syntax actually does a C-style

        T(x) // watch out if T is a pointer!

Here's what I think might be a correct implementation:

     template <class T, class U> T implicit_cast(U const& x) { return x; }
     template <class T, class U> T implicit_cast(U& x) { return x; }


                       David Abrahams
   dave_at_[hidden] *
Boost support, enhancements, training, and commercial distribution

Boost list run by bdawes at, gregod at, cpdaniel at, john at