STYLE: Pefer = default to explicitly trivial implementations

This check replaces default bodies of special member functions with
= default;. The explicitly defaulted function declarations enable more
opportunities in optimization, because the compiler might treat
explicitly defaulted functions as trivial.

Additionally, the C++11 use of = default more clearly expreses the
intent for the special member functions.

SRCDIR=/Users/johnsonhj/src/jsoncpp/ #My local SRC
BLDDIR=/Users/johnsonhj/src/jsoncpp/cmake-build-debug/ #My local BLD

cd /Users/johnsonhj/src/jsoncpp/cmake-build-debug/
run-clang-tidy.py -extra-arg=-D__clang__ -checks=-*,modernize-use-equals-default  -header-filter=.* -fix
This commit is contained in:
Hans Johnson
2019-01-14 17:09:26 -06:00
committed by Hans Johnson
parent e817e4fc25
commit e3e05c7085
8 changed files with 20 additions and 20 deletions

View File

@@ -346,14 +346,14 @@ JSONCPP_STRING valueToQuotedString(const char* value) {
// Class Writer
// //////////////////////////////////////////////////////////////////
Writer::~Writer() {}
Writer::~Writer() = default;
// Class FastWriter
// //////////////////////////////////////////////////////////////////
FastWriter::FastWriter()
{}
= default;
void FastWriter::enableYAMLCompatibility() { yamlCompatibilityEnabled_ = true; }
@@ -428,7 +428,7 @@ void FastWriter::writeValue(const Value& value) {
// //////////////////////////////////////////////////////////////////
StyledWriter::StyledWriter()
{}
= default;
JSONCPP_STRING StyledWriter::write(const Value& root) {
document_.clear();
@@ -1156,10 +1156,10 @@ bool BuiltStyledStreamWriter::hasCommentForValue(const Value& value) {
// StreamWriter
StreamWriter::StreamWriter() : sout_(nullptr) {}
StreamWriter::~StreamWriter() {}
StreamWriter::Factory::~Factory() {}
StreamWriter::~StreamWriter() = default;
StreamWriter::Factory::~Factory() = default;
StreamWriterBuilder::StreamWriterBuilder() { setDefaults(&settings_); }
StreamWriterBuilder::~StreamWriterBuilder() {}
StreamWriterBuilder::~StreamWriterBuilder() = default;
StreamWriter* StreamWriterBuilder::newStreamWriter() const {
JSONCPP_STRING indentation = settings_["indentation"].asString();
JSONCPP_STRING cs_str = settings_["commentStyle"].asString();