Skip to content
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

Add more flexibility to basic_json's ObjectType (and ArrayType) #2013

Closed
1410rlH opened this issue Mar 26, 2020 · 3 comments
Closed

Add more flexibility to basic_json's ObjectType (and ArrayType) #2013

1410rlH opened this issue Mar 26, 2020 · 3 comments
Labels
kind: enhancement/improvement solution: wontfix the issue will not be fixed (either it is impossible or deemed out of scope)

Comments

@1410rlH
Copy link

1410rlH commented Mar 26, 2020

Custom ObjectTypes are in hard limits:

basic_json<> // ok
basic_json<std::map> // ok (the same)
template<class Key, class Value, class Comp, class Alloc> 
my_stl_like_map {};
basic_json<my_stl_like_map> // ok (the same)

basic_json<std::unordered_map> // Won't compile (hash != comparator)

template<class Key, class Value> 
MyMap {};
basic_json<MyMap> // Won't compile (too few templates)

I suggest changing the following line with some metaprogramming or using only Key and Value:

    using object_t = ObjectType<StringType,
          basic_json,
/* Maybe leave those below as default (won't allow custom allocators :( ) */
          object_comparator_t,
          AllocatorType<std::pair<const StringType,
          basic_json>>>;
@nlohmann
Copy link
Owner

Though this adds flexibility, it would also remove flexibility for custom allocators and custom comparators, right?

@1410rlH
Copy link
Author

1410rlH commented Apr 5, 2020 via email

@nlohmann
Copy link
Owner

As this would break the API, I cannot introduce the change without more benefits. Sorry.

@nlohmann nlohmann added the solution: wontfix the issue will not be fixed (either it is impossible or deemed out of scope) label Apr 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement/improvement solution: wontfix the issue will not be fixed (either it is impossible or deemed out of scope)
Projects
None yet
Development

No branches or pull requests

2 participants