I try to use boost::in_place for the non-movable and non-copyable object which constructor takes other object by the reference:
struct A
{
};
struct B
{
B(A& a): a_(a){}
B(B const &) = delete;
B(B&&) = delete;
B& operator=(B const &) = delete;
B& operator=(B&) = delete;
A& a_;
};
int main()
{
A a;
boost::optional<B> op(boost::in_place(a));
return 0;
}
The code doesn't compile: binding reference of type ‘A&’ to ‘const A’ discards qualifiers
How to fix that ?
Aucun commentaire:
Enregistrer un commentaire