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

Unnecessary const_cast #162

Closed
gregmarr opened this issue Dec 28, 2015 · 1 comment
Closed

Unnecessary const_cast #162

gregmarr opened this issue Dec 28, 2015 · 1 comment
Assignees
Milestone

Comments

@gregmarr
Copy link
Contributor

inline nlohmann::json operator "" _json(const char* s, std::size_t)
{
    return nlohmann::json::parse(reinterpret_cast<nlohmann::json::string_t::value_type*>
                                 (const_cast<char*>(s)));
}

The const_cast<char *>() can be removed simply by adding const to the reinterpret_cast.

return nlohmann::json::parse(reinterpret_cast<const nlohmann::json::string_t::value_type*>(s));
@nlohmann
Copy link
Owner

Thanks for the hint! (And thanks so much for helping in so many discussions!)

@nlohmann nlohmann self-assigned this Jan 1, 2016
@nlohmann nlohmann added this to the Release 1.0.1 milestone Jan 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants