diff --git a/libdevcore/CommonData.h b/libdevcore/CommonData.h index e76a09491133..b85abe95101f 100644 --- a/libdevcore/CommonData.h +++ b/libdevcore/CommonData.h @@ -183,6 +183,12 @@ template std::vector& operator+=(std::vector& _a, U con _a.push_back(i); return _a; } +/// Concatenate the contents of a container onto a vector, move variant. +template std::vector& operator+=(std::vector& _a, U&& _b) +{ + std::move(_b.begin(), _b.end(), std::back_inserter(_a)); + return _a; +} /// Concatenate the contents of a container onto a set template std::set& operator+=(std::set& _a, U const& _b) { @@ -197,6 +203,17 @@ inline std::vector operator+(std::vector const& _a, std::vector const& ret += _b; return ret; } +/// Concatenate two vectors of elements, moving them. +template +inline std::vector operator+(std::vector&& _a, std::vector&& _b) +{ + std::vector ret(std::move(_a)); + if (&_a == &_b) + ret += ret; + else + ret += std::move(_b); + return ret; +} template bool contains(T const& _t, V const& _v)