-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
General map-like conversions #518
Comments
I tested and it does indeed work. For example: enum class K { A, B, C };
// tag_invoke for K removed for brevity
check(std::map<K, int> {
{ K::A, 1 }, { K::B, 2}, { K::C, 3},
}); I have to comment that serializing maps into arrays is suboptimal. If we could check during compilation that |
So, since #515 we do support all associative containers.
Should we pursue the former to expand to maps with keys that convert to/from enum class E { e1, e2, e3 };
void tag_invoke(json::value_from_tag, json::value& jv, E e);
std::map<E, X> my_map;
auto jv = value_from(my_map); |
I don't know |
If #989 is done, this could be supported. E.g.: enum class E { e1, e2, e3 };
struct E_String { // is_string_like
E e;
E_String(E);
explicit E_String(string_view);
operator string_view() const;
};
namespace boost::json {
template<>
struct serialize_as<E> : mp11::identity<E_String> {};
}
std::map<E, X> my_map;
auto jv = value_from(my_map); |
let someone ask for it :) |
The text was updated successfully, but these errors were encountered: