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

Allow for forward declaring nlohmann::json #381

Closed
marton78 opened this issue Dec 6, 2016 · 3 comments
Closed

Allow for forward declaring nlohmann::json #381

marton78 opened this issue Dec 6, 2016 · 3 comments
Labels
kind: enhancement/improvement solution: duplicate the issue is a duplicate; refer to the linked issue instead

Comments

@marton78
Copy link

marton78 commented Dec 6, 2016

To avoid including json.hpp in header files, I would like to forward declare nlohmann::json as follows:

namespace nlohmann { struct json; }

struct my_stuff
{
    int some_member;
    nlohmann::json encode() const;
    void decode(nlohmann::json const&);
};

However, this doesn't work, since nlohmann::json is a typedef. If you just derived it from basic_json<>, it would work:

struct json : basic_json<>
{
    using basic_json<>::basic_json;
};

What do you think?

@gregmarr
Copy link
Contributor

gregmarr commented Dec 6, 2016

See discussions in #314

@nlohmann
Copy link
Owner

nlohmann commented Dec 6, 2016

@marton78 Please add this idea to #314.

@nlohmann nlohmann closed this as completed Dec 6, 2016
@nlohmann nlohmann added kind: enhancement/improvement solution: duplicate the issue is a duplicate; refer to the linked issue instead labels Dec 6, 2016
@gregmarr
Copy link
Contributor

gregmarr commented Dec 6, 2016

@nlohmann @marton78 That idea was already mentioned in #314.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement/improvement solution: duplicate the issue is a duplicate; refer to the linked issue instead
Projects
None yet
Development

No branches or pull requests

3 participants