json/doc/mkdocs/docs/api/basic_json
Florian Albrechtskirchinger 5352856f04
Implement support for string_view (attempt no. 3) (#3423)
* Add key_compare member to ordered_map

* Replace == with key_compare in ordered_map

* Expose the actual comparison function used by object_t

nlohmann::ordered_map uses a different comparison function than the one
provided via template parameter.
* Introduce a type trait to detect if object_t has a key_compare member.
* Rename object_comparator_t to default_object_comparator_t.
* Add object_comparator_t to be conditionally defined as
  object_t::key_compare, if available, or default_object_comparator_t
  otherwise.
* Update the documentation accordingly.

Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>

* Add type traits to check if a type is usable as object key

Add type trait to check:
* if a type is a specialization of a template.
* if a type is a json_pointer.
* if a type is a basic_json::{const_,}iterator.
* if two types are comparable using a given comparison functor.
* if a type is comparable to basic_json::object_t::key_type.
* if a type has a member type is_transparent.
* if a type is usable as object key.
* if a type has an erase() function accepting a given KeyType.

Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>

* Rework basic_json element access to accept more key types

Rework basic_json element access member functions and operators to
accept any type that meets the requirements defined by type trait
detail::is_usable_as_key_type.

Member functions and operators:
* at()
* operator[]
* value()
* erase()
* find()
* count()
* contains()

Update documentation to reflect these changes.

Add unit tests to excercise the new functions using std::string_view.

Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>

Co-authored-by: Niels Lohmann <niels.lohmann@gmail.com>
2022-04-29 21:40:02 +02:00
..
~basic_json.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
accept.md 📝 improve documentation InputType and IteratorType (#3246) 2022-01-04 15:02:39 +01:00
array_t.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
array.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
at.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
back.md Overwork documentation (#3444) 2022-04-25 22:40:45 +02:00
basic_json.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
begin.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
binary_t.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
binary.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
boolean_t.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
cbegin.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
cbor_tag_handler_t.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
cend.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
clear.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
contains.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
count.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
crbegin.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
crend.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
default_object_comparator_t.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
diff.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
dump.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
emplace_back.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
emplace.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
empty.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
end.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
erase.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
error_handler_t.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
exception.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
find.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
flatten.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
from_bson.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
from_cbor.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
from_msgpack.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
from_ubjson.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
front.md Overwork documentation (#3444) 2022-04-25 22:40:45 +02:00
get_allocator.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
get_binary.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
get_ptr.md Overwork documentation (#3444) 2022-04-25 22:40:45 +02:00
get_ref.md Overwork documentation (#3444) 2022-04-25 22:40:45 +02:00
get_to.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
get.md Overwork documentation (#3444) 2022-04-25 22:40:45 +02:00
index.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
input_format_t.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
insert.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
invalid_iterator.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
is_array.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
is_binary.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
is_boolean.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
is_discarded.md Overwork documentation (#3444) 2022-04-25 22:40:45 +02:00
is_null.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
is_number_float.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
is_number_integer.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
is_number_unsigned.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
is_number.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
is_object.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
is_primitive.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
is_string.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
is_structured.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
items.md Overwork documentation (#3444) 2022-04-25 22:40:45 +02:00
json_serializer.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
max_size.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
merge_patch.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
meta.md Overwork documentation (#3444) 2022-04-25 22:40:45 +02:00
number_float_t.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
number_integer_t.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
number_unsigned_t.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
object_comparator_t.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
object_t.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
object.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
operator_eq.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
operator_ge.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
operator_gt.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
operator_gtgt.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
operator_le.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
operator_literal_json_pointer.md 📝 overwork documentation 2022-01-09 14:32:38 +01:00
operator_literal_json.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
operator_lt.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
operator_ltlt.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
operator_ne.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
operator_value_t.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
operator_ValueType.md Overwork documentation (#3444) 2022-04-25 22:40:45 +02:00
operator[].md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
operator+=.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
operator=.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
other_error.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
out_of_range.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
parse_error.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
parse_event_t.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
parse.md 📝 improve documentation InputType and IteratorType (#3246) 2022-01-04 15:02:39 +01:00
parser_callback_t.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
patch.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
push_back.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
rbegin.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
rend.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
sax_parse.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
size.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
std_hash.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
std_swap.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
string_t.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
swap.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
to_bson.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
to_cbor.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
to_msgpack.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
to_string.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
to_ubjson.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00
type_error.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
type_name.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
type.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
unflatten.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
update.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
value_t.md Consolidate documentation (#3071) 2021-12-29 13:41:01 +01:00
value.md Implement support for string_view (attempt no. 3) (#3423) 2022-04-29 21:40:02 +02:00