Add copy constructor back
Now that there is a move constructor, it wants an exact copy
constructor. Add that back. And clean up operator=() as well with the
same fix.
Change-Id: I8d7b9f3c65ed7edbd389613637a7714c6d37ab41
diff --git a/aos/flatbuffers.h b/aos/flatbuffers.h
index 4388687..c1c0db0 100644
--- a/aos/flatbuffers.h
+++ b/aos/flatbuffers.h
@@ -127,14 +127,23 @@
FlatbufferVector(const Flatbuffer<T> &other)
: data_(other.data(), other.data() + other.size()) {}
+ // Copy constructor.
+ FlatbufferVector(const FlatbufferVector<T> &other)
+ : data_(other.data(), other.data() + other.size()) {}
+
// Move constructor.
- FlatbufferVector(Flatbuffer<T> &&other) : data_(std::move(other.data())) {}
+ FlatbufferVector(FlatbufferVector<T> &&other)
+ : data_(std::move(other.data_)) {}
// Copies the data from the other flatbuffer.
- FlatbufferVector &operator=(const Flatbuffer<T> &other) {
+ FlatbufferVector &operator=(const FlatbufferVector<T> &other) {
data_ = std::vector<uint8_t>(other.data(), other.data() + other.size());
return *this;
}
+ FlatbufferVector &operator=(FlatbufferVector<T> &&other) {
+ data_ = std::move(other.data_);
+ return *this;
+ }
// Constructs an empty flatbuffer of type T.
static FlatbufferVector<T> Empty() {