-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
detail namespace collision with Cereal? #1082
Comments
The using namespace cereal;
using namespace nlohmann; I don't see how that could be a problem, lots of libraries have a Unfortunately I've never used cereal, let's hope you get more info on the other issue! |
I've confirmed that the break occurs precisely from The following minimum example compiles under #include <json.hpp>
#include <cereal/archives/binary.hpp>
#include <cereal/access.hpp> //So we can make serialize private so developers aren't tempted to call it.
#include <cereal/types/string.hpp> //This is needed to serialize std::string. There are similar ones for the other std containers
#include <cereal/types/vector.hpp> //This is needed to serialize std::vector. There are similar ones for the other std containers
using namespace std;
class Bug
{
public:
std::string text;
void load(const nlohmann::json & s) {};
private:
friend class cereal::access;
template <class Archive> void serialize(Archive &ar) {ar(text);};
};
int main()
{
Bug obj;
std::ostringstream os;
{
cereal::BinaryOutputArchive oarchive(os);
oarchive(obj);
}
Bug obj2;
std::istringstream is(os.str());
{
cereal::BinaryInputArchive iarchive(is);
iarchive(obj2);
}
return 0;
} Note that under |
Update: I've confirmed it is definitely not a namespace collision. I renamed |
This sounds like it is more an issue on Cereal's side. I'm note sure how to proceed here. |
Something in the transition from |
Thanks! |
I'm seeing a very strange bug when using your library in conjunction with C++ Cereal: https://github.com/USCiLab/cereal
Reproduce with the following:
This code, when compiled with the latest
nlohmann::json
throws the following:Curiously though, compiling against a 2.X version of
nlohmann::json
does not produce this exception.I noticed this only happens when the method in the
Bug
class isload
, which is why I'm opening an issue with cereal as well.I noticed one change from
nlohmann::json
2.X->3.X is the inclusion of thenlohmann::detail
namespace. Could this be somehow conflicting withcereal::detail
? I will also open an issue againstcereal
as well.Still trying to figure out root cause of this. It may not be your library, just trying to figure out why I can no longer use
nlohmann::json
with Cereal when I upgrade from 2.X to 3.XCereal issue: USCiLab/cereal#499
The text was updated successfully, but these errors were encountered: