limit dv::value templated constructors & refactor

This commit is contained in:
MihailRis
2024-09-19 04:22:57 +03:00
parent 827a09b1d0
commit 4ae141d982
4 changed files with 18 additions and 27 deletions
+15 -6
View File
@@ -7,7 +7,6 @@
#include <vector>
#include <cstring>
#include <stdexcept>
#include <functional>
#include <unordered_map>
namespace util {
@@ -179,12 +178,24 @@ namespace dv {
}
public:
value() : type(value_type::none) {}
value(value_type type);
template<class T>
value(T v) {
/// @brief Constructor for fundamental types
template<typename T>
value(T v, typename std::enable_if_t<std::is_fundamental<T>::value, int*> = 0) {
this->operator=(v);
}
value(std::string v) {
this->operator=(std::move(v));
}
value(std::shared_ptr<objects::Object> v) {
this->operator=(std::move(v));
}
value(std::shared_ptr<objects::List> v) {
this->operator=(std::move(v));
}
value(std::shared_ptr<objects::Bytes> v) {
this->operator=(std::move(v));
}
value(const value& v) noexcept : type(value_type::none) {
this->operator=(v);
@@ -498,8 +509,6 @@ namespace dv {
inline bool is_numeric(const value& val) {
return val.isInteger() && val.isNumber();
}
using to_string_func = std::function<std::string(const value&)>;
}
namespace dv {