Adds further ext deps as-is binaries copies from customers env.
Qt6 Migration CI / migrate (push) Canceled after 0s
Qt6 Migration CI / migrate (push) Canceled after 0s
This commit is contained in:
3700 files changed
+2132394
No files matched your search
+70
@@ -0,0 +1,70 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
|
||||
namespace ddkit {
|
||||
namespace utils {
|
||||
namespace types {
|
||||
|
||||
template <typename T>
|
||||
class Optional {
|
||||
|
||||
private:
|
||||
std::vector<T> &vec;
|
||||
|
||||
public:
|
||||
Optional(std::vector<T> &val) : vec(val) {}
|
||||
|
||||
Optional() = delete;
|
||||
|
||||
T& value() {
|
||||
if(vec.size()) {
|
||||
return vec[0];
|
||||
} else {
|
||||
throw std::out_of_range( "optional is empty" );
|
||||
}
|
||||
}
|
||||
|
||||
T value_or(T defVal) {
|
||||
return vec.size() ? vec[0] : (defVal);
|
||||
}
|
||||
|
||||
void reset() {
|
||||
if (vec.size()) {
|
||||
vec.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void set(const T &val) {
|
||||
if (vec.size()) {
|
||||
vec[0] = val;
|
||||
} else {
|
||||
vec.push_back(val);
|
||||
}
|
||||
}
|
||||
|
||||
bool has_value() const {
|
||||
return vec.size() ? true : false;
|
||||
}
|
||||
|
||||
std::vector<T> &operator*() {
|
||||
return vec[0];
|
||||
}
|
||||
|
||||
std::vector<T> *operator->() {
|
||||
return vec[0];
|
||||
}
|
||||
|
||||
Optional operator=(const T &val) {
|
||||
set(val);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator bool() const {
|
||||
return has_value();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user