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

Modernize: Use "default" for destructors and copy constructors #751

Merged
merged 1 commit into from
Oct 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/yaml-cpp/eventhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct Mark;

class EventHandler {
public:
virtual ~EventHandler() {}
virtual ~EventHandler() = default;

virtual void OnDocumentStart(const Mark& mark) = 0;
virtual void OnDocumentEnd() = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/yaml-cpp/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ class YAML_CPP_API TypedKeyNotFound : public KeyNotFound {
public:
TypedKeyNotFound(const Mark& mark_, const T& key_)
: KeyNotFound(mark_, key_), key(key_) {}
virtual ~TypedKeyNotFound() YAML_CPP_NOEXCEPT {}
virtual ~TypedKeyNotFound() YAML_CPP_NOEXCEPT = default;

T key;
};
Expand Down
8 changes: 2 additions & 6 deletions include/yaml-cpp/node/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ inline Node::Node(const detail::iterator_value& rhs)
m_pMemory(rhs.m_pMemory),
m_pNode(rhs.m_pNode) {}

inline Node::Node(const Node& rhs)
: m_isValid(rhs.m_isValid),
m_invalidKey(rhs.m_invalidKey),
m_pMemory(rhs.m_pMemory),
m_pNode(rhs.m_pNode) {}
inline Node::Node(const Node& rhs) = default;

inline Node::Node(Zombie)
: m_isValid(false), m_invalidKey{}, m_pMemory{}, m_pNode(nullptr) {}
Expand All @@ -57,7 +53,7 @@ inline Node::Node(Zombie, const std::string& key)
inline Node::Node(detail::node& node, detail::shared_memory_holder pMemory)
: m_isValid(true), m_invalidKey{}, m_pMemory(pMemory), m_pNode(&node) {}

inline Node::~Node() {}
inline Node::~Node() = default;

inline void Node::EnsureNodeExists() const {
if (!m_isValid)
Expand Down
2 changes: 1 addition & 1 deletion include/yaml-cpp/node/iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
namespace YAML {
namespace detail {
struct iterator_value : public Node, std::pair<Node, Node> {
iterator_value() {}
iterator_value() = default;
explicit iterator_value(const Node& rhs)
: Node(rhs),
std::pair<Node, Node>(Node(Node::ZombieNode), Node(Node::ZombieNode)) {}
Expand Down
2 changes: 1 addition & 1 deletion src/emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Emitter::Emitter() : m_pState(new EmitterState), m_stream{} {}
Emitter::Emitter(std::ostream& stream)
: m_pState(new EmitterState), m_stream(stream) {}

Emitter::~Emitter() {}
Emitter::~Emitter() = default;

const char* Emitter::c_str() const { return m_stream.str(); }

Expand Down
2 changes: 1 addition & 1 deletion src/emitterstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ EmitterState::EmitterState()
m_hasNonContent(false),
m_docCount(0) {}

EmitterState::~EmitterState() {}
EmitterState::~EmitterState() = default;

// SetLocalValue
// . We blindly tries to set all possible formatters to this value
Expand Down
26 changes: 13 additions & 13 deletions src/exceptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
namespace YAML {

// These destructors are defined out-of-line so the vtable is only emitted once.
Exception::~Exception() YAML_CPP_NOEXCEPT {}
ParserException::~ParserException() YAML_CPP_NOEXCEPT {}
RepresentationException::~RepresentationException() YAML_CPP_NOEXCEPT {}
InvalidScalar::~InvalidScalar() YAML_CPP_NOEXCEPT {}
KeyNotFound::~KeyNotFound() YAML_CPP_NOEXCEPT {}
InvalidNode::~InvalidNode() YAML_CPP_NOEXCEPT {}
BadConversion::~BadConversion() YAML_CPP_NOEXCEPT {}
BadDereference::~BadDereference() YAML_CPP_NOEXCEPT {}
BadSubscript::~BadSubscript() YAML_CPP_NOEXCEPT {}
BadPushback::~BadPushback() YAML_CPP_NOEXCEPT {}
BadInsert::~BadInsert() YAML_CPP_NOEXCEPT {}
EmitterException::~EmitterException() YAML_CPP_NOEXCEPT {}
BadFile::~BadFile() YAML_CPP_NOEXCEPT {}
Exception::~Exception() YAML_CPP_NOEXCEPT = default;
ParserException::~ParserException() YAML_CPP_NOEXCEPT = default;
RepresentationException::~RepresentationException() YAML_CPP_NOEXCEPT = default;
InvalidScalar::~InvalidScalar() YAML_CPP_NOEXCEPT = default;
KeyNotFound::~KeyNotFound() YAML_CPP_NOEXCEPT = default;
InvalidNode::~InvalidNode() YAML_CPP_NOEXCEPT = default;
BadConversion::~BadConversion() YAML_CPP_NOEXCEPT = default;
BadDereference::~BadDereference() YAML_CPP_NOEXCEPT = default;
BadSubscript::~BadSubscript() YAML_CPP_NOEXCEPT = default;
BadPushback::~BadPushback() YAML_CPP_NOEXCEPT = default;
BadInsert::~BadInsert() YAML_CPP_NOEXCEPT = default;
EmitterException::~EmitterException() YAML_CPP_NOEXCEPT = default;
BadFile::~BadFile() YAML_CPP_NOEXCEPT = default;
}

#undef YAML_CPP_NOEXCEPT
Expand Down
2 changes: 1 addition & 1 deletion src/nodebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ NodeBuilder::NodeBuilder()
m_anchors.push_back(nullptr); // since the anchors start at 1
}

NodeBuilder::~NodeBuilder() {}
NodeBuilder::~NodeBuilder() = default;

Node NodeBuilder::Root() {
if (!m_pRoot)
Expand Down
2 changes: 1 addition & 1 deletion src/ostream_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ostream_wrapper::ostream_wrapper(std::ostream& stream)
m_col(0),
m_comment(false) {}

ostream_wrapper::~ostream_wrapper() {}
ostream_wrapper::~ostream_wrapper() = default;

void ostream_wrapper::write(const std::string& str) {
if (m_pStream) {
Expand Down
2 changes: 1 addition & 1 deletion src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Parser::Parser() : m_pScanner{}, m_pDirectives{} {}

Parser::Parser(std::istream& in) : Parser() { Load(in); }

Parser::~Parser() {}
Parser::~Parser() = default;

Parser::operator bool() const {
return m_pScanner.get() && !m_pScanner->empty();
Expand Down
2 changes: 1 addition & 1 deletion src/regex_yaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class YAML_CPP_API RegEx {
explicit RegEx(char ch);
RegEx(char a, char z);
RegEx(const std::string& str, REGEX_OP op = REGEX_SEQ);
~RegEx() {}
~RegEx() = default;

friend YAML_CPP_API RegEx operator!(const RegEx& ex);
friend YAML_CPP_API RegEx operator|(const RegEx& ex1, const RegEx& ex2);
Expand Down
2 changes: 1 addition & 1 deletion src/scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Scanner::Scanner(std::istream& in)
m_indentRefs{},
m_flows{} {}

Scanner::~Scanner() {}
Scanner::~Scanner() = default;

bool Scanner::empty() {
EnsureTokensInQueue();
Expand Down
2 changes: 1 addition & 1 deletion src/setting.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Setting {

class SettingChangeBase {
public:
virtual ~SettingChangeBase() {}
virtual ~SettingChangeBase() = default;
virtual void pop() = 0;
};

Expand Down
2 changes: 1 addition & 1 deletion src/singledocparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ SingleDocParser::SingleDocParser(Scanner& scanner, const Directives& directives)
m_anchors{},
m_curAnchor(0) {}

SingleDocParser::~SingleDocParser() {}
SingleDocParser::~SingleDocParser() = default;

// HandleDocument
// . Handles the next document
Expand Down
5 changes: 2 additions & 3 deletions src/streamcharsource.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ namespace YAML {
class StreamCharSource {
public:
StreamCharSource(const Stream& stream) : m_offset(0), m_stream(stream) {}
StreamCharSource(const StreamCharSource& source)
: m_offset(source.m_offset), m_stream(source.m_stream) {}
StreamCharSource(const StreamCharSource& source) = default;
StreamCharSource(StreamCharSource&&) = default;
StreamCharSource& operator=(const StreamCharSource&) = delete;
StreamCharSource& operator=(StreamCharSource&&) = delete;
~StreamCharSource() {}
~StreamCharSource() = default;

operator bool() const;
char operator[](std::size_t i) const { return m_stream.CharAt(m_offset + i); }
Expand Down