-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
alias object_t::key_type in basic_json #1442
Copy link
Copy link
Closed
Labels
state: please discussplease discuss the issue or vote for your favorite optionplease discuss the issue or vote for your favorite optionstate: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updatedthe issue has not been updated in a while and will be closed automatically soon unless it is updated
Metadata
Metadata
Assignees
Labels
state: please discussplease discuss the issue or vote for your favorite optionplease discuss the issue or vote for your favorite optionstate: stalethe issue has not been updated in a while and will be closed automatically soon unless it is updatedthe issue has not been updated in a while and will be closed automatically soon unless it is updated
I propose simply adding
using key_type = typename object_t::key_type;tobasic_json<>Considering
at()andoperator[]already make use of it in the public interface, it doesn't seem unreasonable.N.B.
mapped_typemight as well be aliased too for completeness.Caveat: I understand that
find()does not return an iterator to astd::pair<key_type, mapped_type>sobasic_json<>can never be a true map-like as it stands, but unlike thekey_typeissue I illustrate lower down, this is something that can be SFINAE'd around.This would be useful when duck-typing
basic_json<>as a map-like type. Specifically, the fact thatstd::string_viewis not implicitly convertible tostd::stringis currently making this difficult.Example: