You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having a question - let me describe the scenario:
I plan to use JSON for Modern C++ to serialize objects used in a library. Other projects using this library should have no knowledge about the method used to save data. So it should be possible to replace the mechanismn by something else in the future without any change of code on the client side. Therefor I don't want to include json.hpp in my library header files.
But forward declaration failed - maybe you can help me to do it the right way. I tried
namespace nlohmann {
class json;
}
Error: using typedef-name 'using json = class nlohmann::basic_json<>' after 'class'
Then I tried
namespace nlohmann {
template<class T> class basic_json;
using json = basic_json<>;
}
Error: wrong number of template arguments (0, should be 1)
I'm aiming to create an abstract template, which can be specialized in classes to be serialized.
I would be happy to have an answer for my question or any suggestions how to achieve my goal. Mybe you could add info about forward declaration to the description.
Activity
gregmarr commentedon Jan 3, 2018
See #700 and #823
aquacrew commentedon Jan 3, 2018
This is not was I was hoping for, but thanks for the answer anyway.
gregmarr commentedon Jan 3, 2018
@aquacrew until such time as the library does it itself, you should be able to copy the forward declaration from #700 into your own code.