move sub-functions of value impls to concrete types

Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
folling 2023-12-03 18:44:09 +01:00 committed by Folling
parent 5d91c89533
commit 7f24d3d064
Signed by: folling
SSH key fingerprint: SHA256:S9qEx5WCFFLK49tE/LKnKuJYM5sw+++Dn6qJbbyxnCY
14 changed files with 339 additions and 119 deletions

View file

@ -39,7 +39,43 @@ void ikarus_value_base_insert(V * value, size_t idx, typename V::data_type new_d
}
}
template<typename V>
void ikarus_value_base_clear(V * value) {
if (auto * data = value->data.template get_if<std::vector<typename V::data_type>>(); data != nullptr) {
data->clear();
}
}
template<typename V>
bool ikarus_value_base_is_undefined(V const * value) {
return boost::variant2::holds_alternative<boost::variant2::monostate>(value->data);
}
template<typename V>
void ikarus_value_base_set_undefined(V * value, bool undefined) {
if (undefined) {
value->data = boost::variant2::monostate{};
} else {
value->data = typename V::data_type{};
}
}
template<typename V>
bool ikarus_value_base_is_equal(V const * lhs, V const * rhs) {
return lhs->data == rhs->data;
}
template<typename V>
V * ikarus_value_base_copy(V const * value) {
return new V{*value};
}
template<typename V>
struct IkarusValue * ikarus_value_base_to_value(V * value) {
return static_cast<IkarusValue *>(value);
}
template<typename V>
struct IkarusValue const * ikarus_value_base_to_value_const(V const * value) {
return static_cast<IkarusValue const *>(value);
}