Ist es möglich einen Boost zu verschieben :: optional?
Ich habe versucht, einen standardmäßigen Verschiebungskonstruktor in einer Klasse mit einem zu definierenboost::optional
Mitgliedsvariable.
#include <boost/optional.hpp>
#include <utility>
#include <vector>
struct bar {std::vector<int> vec;};
struct foo {
foo() = default;
foo(foo&&) = default;
boost::optional<bar> hello;
};
int main() {
foo a;
foo b(std::move(a));
}
Mein Compiler unterstützt sowohl die Verschiebungssemantik als auch standardmäßige Verschiebungskonstruktoren, aber ich kann dies nicht zum Laufen bringen.
% clang++ foo.cc -std=c++11 -stdlib=libc++
foo.cc:15:7: error: call to deleted constructor of 'foo'
foo b(std::move(a));
^ ~~~~~~~~~~~~
foo.cc:9:3: note: function has been explicitly marked deleted here
foo(foo&&) = default;
^
1 error generated.
Gibt es eine Möglichkeit, aboost::optional
ohne den Quellcode von Boost ändern? Oder soll ich warten, bis Boost den Umzug unterstützt?
Ich hatte das gleiche Problem mitboost::any
in der Vergangenheit.