Skip to content

Make Value( bool value ) etc explicit #1159

Open
@xingjy10

Description

@xingjy10

when passing a Json::Value pointer to a const Json::Value &;
compiler will automatically transform the pointer to bool then to a json::value;

void LogJson(const Json::Value& value) {
  LOG(ERROR) << value.toStyledString();
}
int main() {
  Json::Value json = Json::Value(Json::objectValue)
  const Json::Value *json_p = &json;
  LogJson(json);
  LogJson(json_p);
}

the first LogJson will log a "{}"
the second LogJson will log a "true", caused by implict conversation

Expecte the second LogJson will compile fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions