Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler error when using macro NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE #4463

Open
1 of 2 tasks
ramitrathore opened this issue Sep 18, 2024 · 1 comment
Open
1 of 2 tasks
Labels
solution: invalid the issue is not related to the library

Comments

@ramitrathore
Copy link

Description

struct Contain
{
Contain() = delete; //Enable the default constructor to make it work
explicit Contain(std::string contain) : m_Contain(std::move(contain)){}
std::string m_Contain;
};

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Contain, m_Contain);

struct Container
{
std::string m_Name;
std::vector m_Collection;
};

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Container, m_Name, m_Collection); //Compiler error

Reproduction steps

Compiler error - can be easily reproduce since I have added snippet code

Expected vs. actual results

Compiler error

Minimal code example

struct Contain
{
	Contain() = delete; //Enable the default constructor to make it work
  explicit Contain(std::string contain) : m_Contain(std::move(contain)){}
	std::string m_Contain;
};

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Contain, m_Contain);

struct Container
{
	std::string m_Name;
	std::vector<Contain> m_Collection;
};

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Container, m_Name, m_Collection); //Compiler error

Error messages

Compiler error

Compiler and operating system

Windows 10

Library version

3.11.3

Validation

@nlohmann
Copy link
Owner

The documentation (https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/#notes) states the type must be default constructible to use the macro.

@nlohmann nlohmann added solution: invalid the issue is not related to the library and removed kind: bug labels Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
solution: invalid the issue is not related to the library
Projects
None yet
Development

No branches or pull requests

2 participants