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

How to support object containers outside std? #1580

Open
meastp opened this issue Jan 30, 2025 · 1 comment
Open

How to support object containers outside std? #1580

meastp opened this issue Jan 30, 2025 · 1 comment

Comments

@meastp
Copy link

meastp commented Jan 30, 2025

I tried to find the source code for supporting std::map / std::unordered_map in glaze, but couldn't find it.

Could you point to the source and/or give an example how to support other object/map containers?

There are containers, e.g. boost.unordered that are a lot faster than std:: which I would like to use... :)

Perhaps this would increase the performance of json pointer lookup (through one or more object containers) as well?

@stephenberry
Copy link
Owner

Glaze uses C++20 concepts to support types, this means that Glaze supports std::map / std::unordered_map and any containers that have similar APIs. So, a lot of third party maps optimized for different use cases will just work automatically.

In common.hpp there are the following concepts for maps:

template <class T>
concept readable_map_t = !custom_read<T> && !meta_value_t<T> && !str_t<T> && range<T> &&
                         pair_t<range_value_t<T>> && map_subscriptable<std::decay_t<T>>;

template <class T>
concept writable_map_t = !custom_write<T> && !meta_value_t<T> && !str_t<T> && range<T> &&
                         pair_t<range_value_t<T>> && map_subscriptable<std::decay_t<T>>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants