47 #include <type_traits>
58 template<
typename DataModel>
59 void invokeSetWithEachArgument(DataModel && )
64 template<
typename DataModel,
typename Arg,
typename... Args>
65 void invokeSetWithEachArgument(DataModel &&dm, Arg &&arg, Args &&...args)
67 dm.set(std::forward<Arg>(arg));
68 invokeSetWithEachArgument(std::forward<DataModel>(dm), std::forward<Args>(args)...);
77 static_assert(std::is_default_constructible<T>::value,
"T needs to be default_constructible");
85 explicit constexpr Optional(
const T &value)
90 explicit constexpr Optional(T &&value)
92 , m_value{ std::move(value) }
95 const T &value()
const
99 throw std::runtime_error(
"value() called on unset optional");
104 bool hasValue()
const
115 bool operator==(
const Optional<T> &other)
const
117 if(hasValue() != other.hasValue())
return false;
118 if(!hasValue())
return true;
119 return value() == other.value();
122 bool operator!=(
const Optional<T> &other)
const
124 return !operator==(other);
127 bool operator<(
const Optional<T> &other)
const
129 if(!hasValue() && !other.hasValue())
return false;
130 if(hasValue() && !other.hasValue())
return false;
131 if(!hasValue() && other.hasValue())
return true;
132 return m_value < other.m_value;
135 bool operator>(
const Optional<T> &other)
const
137 if(!hasValue() && !other.hasValue())
return false;
138 if(hasValue() && !other.hasValue())
return true;
139 if(!hasValue() && other.hasValue())
return false;
140 return m_value > other.m_value;
151 static void setFromString(T &target,
const std::string &value)
153 target.setFromString(value);
156 static void setFromString(T &target,
const std::string &path,
const std::string &value)
158 target.setFromString(path, value);
161 static std::string getString(
const T &target,
const std::string &path)
163 return target.getString(path);
168 void setFromString(T &target,
const std::string &value)
170 Befriend<T>::setFromString(target, value);
174 void setFromString(T &target,
const std::string &path,
const std::string &value)
176 Befriend<T>::setFromString(target, path, value);
180 std::string getString(
const T &target,
const std::string &path)
182 return Befriend<T>::getString(target, path);
The main Zivid namespace. All Zivid code is found here
Definition: Application.h:55