Opened 15 years ago

Closed 12 years ago

#1785 closed Bugs (invalid)

assign::list_of works poorly with class constructors

Reported by: tailsu@… Owned by: Thorsten Ottosen
Milestone: Boost 1.36.0 Component: assign
Version: Boost 1.35.0 Severity: Problem
Keywords: list_of Cc:

Description

try compiling the following snippet:

#include <boost/assign/list_of.hpp> using namespace boost::assign;

class foo { public:

foo(const vector<int>& a) {}

};

void bar() {

foo a(list_of(0));

}

at the line 'foo a(list_of(0))' the compiler (VC8) thinks I want to call the copy contructor of foo, instead of the constructor that would cause a conversion to vector<int>. This case requires an explicit conversion, or using a different constructor prototype that doesn't overload the copy constructor.

Please, advise which is the best way to use list_of in this scenario.

Change History (2)

comment:1 by Thorsten Ottosen, 14 years ago

Status: newassigned

Does

foo a((vector<int>)list_of(0));

not work?

-Thorsten

comment:2 by Thorsten Ottosen, 12 years ago

Resolution: invalid
Status: assignedclosed
Note: See TracTickets for help on using tickets.