Skip to content

Commit

Permalink
chore: move function define
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Jan 23, 2024
1 parent b0785dd commit 279edb9
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions include/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ class basic_value
template <typename value_t>
bool is() const noexcept;

template <typename value_t>
bool all() const;

bool contains(const string_t& key) const;
bool contains(size_t pos) const;
bool exists(const string_t& key) const { return contains(key); }
Expand Down Expand Up @@ -181,6 +184,12 @@ class basic_value
string_t as_string() const;
const basic_array<string_t>& as_array() const;
const basic_object<string_t>& as_object() const;

template <typename value_t, template <typename...> typename collection_t = std::vector>
collection_t<value_t> as_collection() const;
template <typename value_t, template <typename...> typename map_t = std::map>
map_t<string_t, value_t> as_map() const;

template <typename value_t>
value_t as() const;

Expand Down Expand Up @@ -210,21 +219,14 @@ class basic_value
return format(indent, 0);
}

template <typename value_t>
bool all() const;
template <typename value_t, template <typename...> typename collection_t = std::vector>
collection_t<value_t> as_collection() const;
template <typename value_t, template <typename...> typename map_t = std::map>
map_t<string_t, value_t> as_map() const;

template <typename value_t, template <typename...> typename vector_t = std::vector>
// deprecated, please use as_collection instead.
// deprecated, please use `as_collection` instead.
vector_t<value_t> to_vector() const
{
return to_vector<value_t, vector_t>();
}
template <typename value_t, template <typename...> typename map_t = std::map>
// deprecated, please use as_map instead.
// deprecated, please use `as_map` instead.
map_t<string_t, value_t> to_map() const
{
return as_map<value_t, map_t>();
Expand Down

0 comments on commit 279edb9

Please sign in to comment.