Skip to content

variant is not support in Release 3.6.1? #1615

Closed
@zhongcy

Description

@nlohmann @theodelrieu
Hi, variant is not support in Release 3.6.1? Have any Variant examples?
I test the example that it's not success in Release 3.6.1.

#include "json.hpp"
#include <variant>
#include <iostream>

int main() {
	std::variant<int, float, std::string> t = 3.14159f;
	std::cout << nlohmann::json(t).dump() << std::endl;
}

variant.cpp: In function ‘int main()’: variant.cpp:17:31: error: no matching function for call to ‘nlohmann::basic_json<>::basic_json(std::variant<int, float>&)’ std::cout << nlohmann::json(t).dump() << std::endl; ^ In file included from variant.cpp:3:0: /nlohmann/json.hpp:1841:5: note: candidate: nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>::basic_json(nlohmann::basic_json<ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer>&&) [with ObjectType = std::map; ArrayType = std::vector; StringType = std::basic_string<char>; BooleanType = bool; NumberIntegerType = long int; NumberUnsignedType = long unsigned int; NumberFloatType = double; AllocatorType = std::allocator; JSONSerializer = nlohmann::adl_serializer] basic_json(basic_json&& other) noexcept

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions