From 62fe57479e7d8949e4ed2e0efb31238d5d8d6d0a Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Wed, 12 Dec 2018 14:51:22 +0100 Subject: make use of C++ `= default` constructor declarations as well as more non-static member initialization syntax. --- liblangutil/CharStream.h | 6 +++--- liblangutil/EVMVersion.h | 2 +- liblangutil/SourceReferenceExtractor.h | 25 +++++++++++++------------ 3 files changed, 17 insertions(+), 16 deletions(-) (limited to 'liblangutil') diff --git a/liblangutil/CharStream.h b/liblangutil/CharStream.h index f92beb30..0c998b2a 100644 --- a/liblangutil/CharStream.h +++ b/liblangutil/CharStream.h @@ -67,9 +67,9 @@ namespace langutil class CharStream { public: - CharStream(): m_position(0) {} + CharStream() = default; explicit CharStream(std::string const& _source, std::string const& name): - m_source(_source), m_name(name), m_position(0) {} + m_source(_source), m_name(name) {} int position() const { return m_position; } bool isPastEndOfInput(size_t _charsForward = 0) const { return (m_position + _charsForward) >= m_source.size(); } @@ -94,7 +94,7 @@ public: private: std::string m_source; std::string m_name; - size_t m_position; + size_t m_position{0}; }; } diff --git a/liblangutil/EVMVersion.h b/liblangutil/EVMVersion.h index 657727ac..21889bd9 100644 --- a/liblangutil/EVMVersion.h +++ b/liblangutil/EVMVersion.h @@ -39,7 +39,7 @@ class EVMVersion: boost::equality_comparable { public: - EVMVersion() {} + EVMVersion() = default; static EVMVersion homestead() { return {Version::Homestead}; } static EVMVersion tangerineWhistle() { return {Version::TangerineWhistle}; } diff --git a/liblangutil/SourceReferenceExtractor.h b/liblangutil/SourceReferenceExtractor.h index 0be7e9d8..bcbc50bc 100644 --- a/liblangutil/SourceReferenceExtractor.h +++ b/liblangutil/SourceReferenceExtractor.h @@ -31,28 +31,29 @@ namespace langutil struct LineColumn { - int line; - int column; + int line = {-1}; + int column = {-1}; + LineColumn() = default; LineColumn(std::tuple const& _t): line{std::get<0>(_t)}, column{std::get<1>(_t)} {} - LineColumn(int _line, int _column): line{_line}, column{_column} {} - LineColumn(): line{-1}, column{-1} {} }; struct SourceReference { - std::string message; ///< A message that relates to this source reference (such as a warning or an error message). - std::string sourceName; ///< Underlying source name (for example the filename). - LineColumn position; ///< Actual (error) position this source reference is surrounding. - bool multiline; ///< Indicates whether the actual SourceReference is truncated to one line. - std::string text; ///< Extracted source code text (potentially truncated if multiline or too long). - int startColumn; ///< Highlighting range-start of text field. - int endColumn; ///< Highlighting range-end of text field. + std::string message; ///< A message that relates to this source reference (such as a warning or an error message). + std::string sourceName; ///< Underlying source name (for example the filename). + LineColumn position; ///< Actual (error) position this source reference is surrounding. + bool multiline = {false}; ///< Indicates whether the actual SourceReference is truncated to one line. + std::string text; ///< Extracted source code text (potentially truncated if multiline or too long). + int startColumn = {-1}; ///< Highlighting range-start of text field. + int endColumn = {-1}; ///< Highlighting range-end of text field. /// Constructs a SourceReference containing a message only. static SourceReference MessageOnly(std::string _msg) { - return SourceReference{std::move(_msg), "", LineColumn{-1, -1}, false, "", -1, -1}; + SourceReference sref; + sref.message = std::move(_msg); + return sref; } }; -- cgit