Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2005-03-21 12:23:36


"Jens Theisen" <jens.theisen_at_[hidden]> wrote in message
news:d1k5kt$k8m$1_at_sea.gmane.org...
| implicit_cast was once in cast.hpp, but as the comments says, it has
| been removed due to uncertain purpose. I have to purposes of which I am
| wondering how to do them otherwise:
|
| 1. take the address of the conversion
| 2. initialise a std::vector< int > with a boost::assign::list_of in a
| constructor initialiser
|
| The latter is a bit subtle.

indeed.

| ambiguity. Using implicit_cast solves the problem, since then the
| constructor call to std::vector and the call to the conversion operator
| in list_of are both taken as user defined conversions, and there can
| only be one of them.
|
| vector< int > v = list_of(1)(2); // works
|
| vector< int > v(list_of(1)(2)); // ambiguous
|
| ctor() : v(implicit_cast< vector< int > >(list_of(1)(2)))
| { } // ambiguous
|
| ctor() : v(list_of(1)(2)) { } // ambiguous
|
| Any thoughts on this?

what about

ctor() : v( list_of(1)(2).to_container(v) )
{ }

?

-Thorsten


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