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

GenericValue: explicit constructors #11

Merged
merged 1 commit into from
Jun 25, 2014
Merged

Conversation

pah
Copy link
Contributor

@pah pah commented Jun 25, 2014

In case of overloaded functions taking either a GenericValue or another
class that can also be constructed from the same primitive types
(e.g. std::string, which can be constructed from const char*), the
overloading becomes ambiguous:

void foo( const std::string& );
void foo( const rapidjson::Value & );

Declaring the GenericValue constructors taking primitive types as
'explicit' avoids this problem. This should not have any negative
side-effects, since a GenericValue can't be copied or implicitly
converted to other types.

Fixes http://code.google.com/p/rapidjson/issues/detail?id=70.

In case of overloaded functions taking either a GenericValue or another
class that can also be constructed from the same primitive types
(e.g. std::string, which can be constructed from const char*), the
overloading becomes ambiguous:

  void foo( const std::string& );
  void foo( const rapidjson::Value & );

Declaring the GenericValue constructors taking primitive types as
'explicit' avoids this problem.  This should not have any negative
side-effects, since a GenericValue can't be copied or implicitly
converted to other types.

Fixes http://code.google.com/p/rapidjson/issues/detail?id=70.
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

Successfully merging this pull request may close these issues.

2 participants