some ctb funcs

This commit is contained in:
Erik Frojdh
2019-08-07 18:00:25 +02:00
parent 21046bcae0
commit bba6e1667b
4 changed files with 65 additions and 26 deletions

View File

@ -31,32 +31,33 @@ 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> */
/** 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>::type>
(std::is_same<T, time::ns>::value ||
std::is_same<T, bool>::value)>::type>
Result(const std::vector<V> &from) {
vec.reserve(from.size());
for (const auto &item : from)
vec.push_back(T(item));
}
/** Custom constructor from integer type to Result<ns> */
/** 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>::type>
(std::is_same<T, time::ns>::value ||
std::is_same<T, bool>::value)>::type>
Result(std::vector<V> &from) {
vec.reserve(from.size());
for (const auto &item : from)
vec.push_back(T(item));
}
/** Custom constructor from integer type to Result<ns> */
/** 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>::type>
(std::is_same<T, time::ns>::value ||
std::is_same<T, bool>::value)>::type>
Result(std::vector<V> &&from) {
vec.reserve(from.size());
for (const auto &item : from)