@@ -33,9 +33,37 @@ using value_base = mapbox::util::variant<null_value_t, bool, uint64_t, int64_t,
3333 mapbox::util::recursive_wrapper<std::vector<value>>,
3434 mapbox::util::recursive_wrapper<std::unordered_map<std::string, value>>>;
3535
36- struct value : value_base
36+ struct value : public value_base
3737{
38- using value_base::value_base;
38+ using array_type = std::vector<value>;
39+ using object_type = std::unordered_map<std::string, value>;
40+
41+ value () : value_base(null_value) {}
42+ value (null_value_t ) : value_base(null_value) {}
43+ value (bool v) : value_base(v) {}
44+ value (const char * c) : value_base(std::string(c)) {}
45+ value (std::string str) : value_base(std::move(str)) {}
46+
47+ template <typename T, typename std::enable_if_t <std::is_integral<T>::value, int > = 0 ,
48+ typename std::enable_if_t <std::is_signed<T>::value, int > = 0 >
49+ value (T t) : value_base(int64_t (t))
50+ {
51+ }
52+
53+ template <typename T, typename std::enable_if_t <std::is_integral<T>::value, int > = 0 ,
54+ typename std::enable_if_t <!std::is_signed<T>::value, int > = 0 >
55+ value (T t) : value_base(uint64_t (t))
56+ {
57+ }
58+
59+ template <typename T, typename std::enable_if_t <std::is_floating_point<T>::value, int > = 0 >
60+ value (T t) : value_base(double (t))
61+ {
62+ }
63+ value (array_type array) : value_base(std::move(array)) {}
64+ value (object_type object) : value_base(std::move(object)) {}
65+
66+ explicit operator bool () const { return !is<null_value_t >(); }
3967};
4068
4169using property_map = std::unordered_map<std::string, value>;
0 commit comments