7 Sep
2009
7 Sep
'09
10:46 p.m.
Stefan Strasser wrote:
I can't figure out how to in-place construct the contents of a boost::variant.
Why do you think that is supported? I see no such thing in the documentation.
so why does the following fail:
struct A : noncopyable{ A(int); A &operator=(int); }; struct B{};
int main(){ A a(5); //ok a=5; //ok variant var(5); //error var=5; //error }
Because variant requires all types it can contain to be CopyConstructible, in particular because it has no support for in-place construction or move semantics.