-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
Adds a to_json function for std::vector<bool> to allow implicit conversion from bit vectors to basic_json.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -324,6 +324,19 @@ struct external_constructor<value_t::array> | |
j.m_value.array = j.template create<typename BasicJsonType::array_t>(begin(arr), end(arr)); | ||
j.assert_invariant(); | ||
} | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
template<typename BasicJsonType> | ||
static void construct(BasicJsonType& j, const std::vector<bool>& arr) | ||
{ | ||
j.m_type = value_t::array; | ||
j.m_value = value_t::array; | ||
j.m_value.array->reserve(arr.size()); | ||
for (bool x : arr) | ||
{ | ||
j.m_value.array->push_back(x); | ||
} | ||
j.assert_invariant(); | ||
} | ||
}; | ||
|
||
template<> | ||
|
@@ -562,6 +575,12 @@ void to_json(BasicJsonType& j, UnscopedEnumType e) noexcept | |
external_constructor<value_t::number_integer>::construct(j, e); | ||
} | ||
|
||
template<typename BasicJsonType> | ||
void to_json(BasicJsonType& j, std::vector<bool> e) noexcept | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
theodelrieu
Contributor
|
||
{ | ||
external_constructor<value_t::array>::construct(j, e); | ||
} | ||
|
||
template < | ||
typename BasicJsonType, typename CompatibleArrayType, | ||
enable_if_t < | ||
|
@theodelrieu This is the way to implement this, right?