mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 21:07:13 +02:00
WIP
This commit is contained in:
@ -13,6 +13,7 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#include "TimeHelper.h"
|
||||
#include "ToString.h"
|
||||
#include "container_utils.h"
|
||||
|
||||
@ -30,6 +31,34 @@ template <class T, class Allocator = std::allocator<T>> class Result {
|
||||
Result() = default;
|
||||
Result(std::initializer_list<T> list) : vec(list){};
|
||||
|
||||
template <typename V, typename = typename std::enable_if<
|
||||
std::is_integral<V>::value &&
|
||||
std::is_same<T, time::ns>::value>::type>
|
||||
Result(const std::vector<V> &from) {
|
||||
|
||||
vec.reserve(from.size());
|
||||
for (const auto &item : from)
|
||||
vec.push_back(T(item));
|
||||
}
|
||||
|
||||
template <typename V, typename = typename std::enable_if<
|
||||
std::is_integral<V>::value &&
|
||||
std::is_same<T, time::ns>::value>::type>
|
||||
Result(std::vector<V> &from) {
|
||||
vec.reserve(from.size());
|
||||
for (const auto &item : from)
|
||||
vec.push_back(T(item));
|
||||
}
|
||||
|
||||
template <typename V, typename = typename std::enable_if<
|
||||
std::is_integral<V>::value &&
|
||||
std::is_same<T, time::ns>::value>::type>
|
||||
Result(std::vector<V> &&from) {
|
||||
vec.reserve(from.size());
|
||||
for (const auto &item : from)
|
||||
vec.push_back(T(item));
|
||||
}
|
||||
|
||||
/**
|
||||
* Forward arguments to the constructor of std::vector
|
||||
* @tparam Args template paramter pack to forward
|
||||
@ -82,9 +111,6 @@ template <class T, class Allocator = std::allocator<T>> class Result {
|
||||
|
||||
/** Convert Result<T> to std::vector<T> */
|
||||
operator std::vector<T>() { return vec; }
|
||||
|
||||
/** Convert Result<T> to T using squash() */
|
||||
operator T() { return squash(); }
|
||||
};
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user