Parallel returns Result

This commit is contained in:
Erik Frojdh
2019-08-09 11:40:57 +02:00
parent dfbf7ab39a
commit fc78bb9384
5 changed files with 50 additions and 14 deletions

View File

@ -31,12 +31,13 @@ template <class T, class Allocator = std::allocator<T>> class Result {
Result() = default;
Result(std::initializer_list<T> list) : vec(list){};
/** Custom constructor from integer type to Result<ns> or Result<bool> */
template <typename V, typename = typename std::enable_if<
std::is_integral<V>::value &&
(std::is_same<T, time::ns>::value ||
std::is_same<T, bool>::value)>::type>
Result(const std::vector<V> &from) {
Result(const Result<V> &from) {
vec.reserve(from.size());
for (const auto &item : from)
vec.push_back(T(item));
@ -47,7 +48,7 @@ template <class T, class Allocator = std::allocator<T>> class Result {
std::is_integral<V>::value &&
(std::is_same<T, time::ns>::value ||
std::is_same<T, bool>::value)>::type>
Result(std::vector<V> &from) {
Result(Result<V> &from) {
vec.reserve(from.size());
for (const auto &item : from)
vec.push_back(T(item));
@ -58,7 +59,7 @@ template <class T, class Allocator = std::allocator<T>> class Result {
std::is_integral<V>::value &&
(std::is_same<T, time::ns>::value ||
std::is_same<T, bool>::value)>::type>
Result(std::vector<V> &&from) {
Result(Result<V> &&from) {
vec.reserve(from.size());
for (const auto &item : from)
vec.push_back(T(item));
@ -90,6 +91,7 @@ template <class T, class Allocator = std::allocator<T>> class Result {
auto empty() const noexcept -> decltype(vec.empty()) { return vec.empty(); }
auto front() -> decltype(vec.front()) { return vec.front(); }
auto front() const -> decltype(vec.front()) { return vec.front(); }
void reserve(size_type new_cap) { vec.reserve(new_cap); }
template <typename V>
auto push_back(V value) -> decltype(vec.push_back(value)) {