Skip to content

incomplete type used in nested name specifier #2811

Answered by Life4gal
Life4gal asked this question in Q&A
Discussion options

You must be logged in to vote
// I forgot this!
struct normal_data {
	int64_t data;
};

struct normal_data_with_layer : normal_data {
	using layer_data = std::array<int64_t, 8>;

	using normal_data::normal_data;

	layer_data layer;
};

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(normal_data, data);
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(normal_data_with_layer, data, layer);

// and parse is not needed
j = nlohmann::json{
	{a1_name, nlohmann::json::parse(data.a1)},
	{a2_name, nlohmann::json::parse(data.a2)},
	{a3_name, nlohmann::json::parse(data.a3)},
	{a4_name, nlohmann::json::parse(data.a4)},
	{a5_name, nlohmann::json::parse(data.a5)}};
}
// but...
// result of std::cout << std::setw(4) << j.dump(4) << std::endl;
[
    {
        "a1

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Life4gal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant