Skip to content

Unnecessary const_cast #162

Closed
Closed

Description

@gregmarr
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));

Activity

  1. nlohmann commented on Dec 29, 2015

    @nlohmann
    Owner

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

  2. self-assigned this
    on Jan 1, 2016
  3. added this to the milestone on Jan 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions