Boost logo

Boost Users :

Subject: Re: [Boost-users] [variant] how to in-place construct a variant
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2009-09-07 18:46:57


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<A,B> 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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net