json
json copied to clipboard
Compiler error when using macro NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE
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<Contain> 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
- [X] The bug also occurs if the latest version from the
developbranch is used. - [ ] I can successfully compile and run the unit tests.
The documentation (https://json.nlohmann.me/api/macros/nlohmann_define_type_intrusive/#notes) states the type must be default constructible to use the macro.