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>.
reflect-cppcurrently supportsstd::map<K, V>with the default comparator, but fails when the map uses a transparent comparator likestd::less<>.This is a common modern C++ pattern because
std::less<>enables heterogeneous lookup (e.g.map.find(std::string_view)without allocating astd::string). It would be great ifreflect-cpptreatedstd::map<K, V, Compare>the same as long as it’s still astd::mapand the key/value types are supported.Minimal Repro
Works
Fails
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 asstd::map<std::string, std::string>.