Commit 480a1b63 authored by Martin Heistermann's avatar Martin Heistermann
Browse files

Properties: implement swap() with vector

parent 22b0aedf
...@@ -104,6 +104,8 @@ public: ...@@ -104,6 +104,8 @@ public:
/// set all values to `val`. /// set all values to `val`.
void fill(T const&val) { storage()->fill(val); } void fill(T const&val) { storage()->fill(val); }
void swap(std::vector<T> &_other) { storage()->swap(_other); }
protected: protected:
PropertyStoragePtr(std::shared_ptr<PropertyStorageT<T>> _ptr = nullptr) PropertyStoragePtr(std::shared_ptr<PropertyStorageT<T>> _ptr = nullptr)
: storage_(std::move(_ptr)) : storage_(std::move(_ptr))
......
...@@ -111,6 +111,12 @@ public: ...@@ -111,6 +111,12 @@ public:
assert(_idx < data_.size()); assert(_idx < data_.size());
data_.erase(data_.begin() + static_cast<long>(_idx)); data_.erase(data_.begin() + static_cast<long>(_idx));
} }
void swap(std::vector<T> &_other) {
if (data_.size() != _other.size()) {
throw std::runtime_error("PropertyStorageT::swap: vector sizes don't match");
}
std::swap(data_, _other);
}
public: public:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment