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

What is the meaning of operator[](T* key) #645

Closed
scinart opened this issue Jul 3, 2017 · 3 comments
Closed

What is the meaning of operator[](T* key) #645

scinart opened this issue Jul 3, 2017 · 3 comments
Assignees
Milestone

Comments

@scinart
Copy link
Contributor

scinart commented Jul 3, 2017

What's the meaning of the following code?

abbreviated version from json.hpp:

template<typename T, std::size_t n>
reference operator[](T * (&key)[n])
{
    return operator[](static_cast<const T>(key));
}
template<typename T>
reference operator[](T* key)
{
    return m_value.object->operator[](key);
}

and const_reference version of them.

Normally m_value.object is an std::map and key is an std::string. But the code must have been placed for a reason. I just want to know why.

@nlohmann
Copy link
Owner

nlohmann commented Jul 7, 2017

Good point. I see the code is currently not covered by any test case. I think it was old code that aimed to avoid a conversion from string literals to string_t. I wonder why they are not used any more.

@nlohmann
Copy link
Owner

nlohmann commented Jul 8, 2017

The code was added in commit 7e32457 to fix issue #171. With current versions of Clang, it seems these functions are not used any more.

nlohmann added a commit that referenced this issue Jul 8, 2017
It seems these functions are not required any more. The code was added in commit 7e32457 to fix issue #171. There are still regression tests for #171, so when this commit passes the CI, the functions may be removed for good.
@nlohmann nlohmann self-assigned this Jul 8, 2017
@nlohmann nlohmann added this to the Release 3.0.0 milestone Jul 8, 2017
@nlohmann
Copy link
Owner

nlohmann commented Jul 8, 2017

I removed the functions and none of the CI compilers complained. Closing this issue. Thanks @scinart for noting!

@nlohmann nlohmann closed this as completed Jul 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants