-
Notifications
You must be signed in to change notification settings - Fork 150
Open
Description
reflect-cpp currently supports std::map<K, V> with the default comparator, but fails when the map uses a transparent comparator like std::less<>.
This is a common modern C++ pattern because std::less<> enables heterogeneous lookup (e.g. map.find(std::string_view) without allocating a std::string). It would be great if reflect-cpp treated std::map<K, V, Compare> the same as long as it’s still a std::map and the key/value types are supported.
Minimal Repro
Works
#include <map>
#include <string>
#include <string_view>
#include <rfl.hpp>
#include <rfl/json.hpp>
#include <rfl/patterns.hpp>
struct Request {
std::map<std::string, std::string> headers;
inline static auto fromJson(std::string_view v) {
return rfl::json::read<Request>(v);
}
};Fails
#include <functional>
#include <map>
#include <string>
#include <string_view>
#include <rfl.hpp>
#include <rfl/json.hpp>
#include <rfl/patterns.hpp>
struct Request {
std::map<std::string, std::string, std::less<>> headers;
inline static auto fromJson(std::string_view v) {
return rfl::json::read<Request>(v);
}
};Actual Behavior
Compilation fails with a static assertion / unsupported type error.
Example (MSVC):
C2338 static assertion failed: 'Unsupported type.'
Expected Behavior
std::map<std::string, std::string, std::less<>> should serialize/deserialize the same way as std::map<std::string, std::string>.
liuzicheng1987 and NiNeDelixe
Metadata
Metadata
Assignees
Labels
No labels