-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
Description
Describe the bug
string_builder uses type_value member type to get the value type of a range when checking whether it is a pair, but that is not correct which leads to compile time error. Not all ranges has value_type as its member type (for example transform_view). The correct way to to do this is using std::ranges::ranges_value_t.
To Reproduce
The code below will fail to compile at line 16:
#include <simdjson.h>
#include <print>
struct Foo
{
int a;
float b;
};
int main()
{
auto vec = std::vector<Foo>{ { 1, 2.0f }, { 3, 4.0f }, { 5, 6.0f }, { 7, 8.0f } };
auto builder = simdjson::builder::string_builder{};
builder.start_object();
builder.append_key_value<"vec">(vec | std::views::transform(&Foo::b)); // << here
builder.end_object();
std::println("{}", builder.view().take_value());
}simjson release
master
Indicate whether you are willing or able to provide a bug fix as a pull request
sure
Reactions are currently unavailable