Skip to content

can't parse std::vector<std::byte> #2869

Closed
@Spongman

Description

@Spongman

this worked in v2.1.1, but no longer works in v3.9.1:

int main() {
	std::vector<std::byte> rg;
	nlohmann::json::parse({rg.begin(), rg.end()});
}
include/nlohmann/nlohmann/json.hpp:5164:40: error: no matching function for call to ‘nlohmann::detail::iterator_input_adapter<const char*>::iterator_input_adapter(nlohmann::detail::iterator_input_adapter_factory<__gnu_cxx::__normal_iterator<std::byte*, std::vector<std::byte> >, void>::adapter_type)’
 5164 |         : ia(input_adapter(first, last)) {}

i tried just passing the iterators directly:

int main() {
	std::vector<std::byte> rg;
	nlohmann::json::parse(rg.begin(), rg.end());
}

but this gives a bunch of these:

include/nlohmann/nlohmann/json.hpp:7423:59: error: cannot convert ‘char’ to ‘std::byte’ in initialization
 7423 |                 std::array<char_type, 4> true_literal = {{'t', 'r', 'u', 'e'}};
      |                                                           ^~~
      |                                                           |
      |                                                           char

Metadata

Metadata

Assignees

Labels

confirmedkind: bugsolution: duplicatethe issue is a duplicate; refer to the linked issue insteadsolution: proposed fixa fix for the issue has been proposed and waits for confirmation

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions