C++11: Improved CppCoreGuidelines compliance

This commit is contained in:
Paul Beckingham 2016-01-19 00:31:11 -05:00
parent f550e8a1a7
commit 6a2b861b1d
2 changed files with 8 additions and 9 deletions

View file

@ -35,9 +35,7 @@
////////////////////////////////////////////////////////////////////////////////
Pig::Pig (const std::string& text)
: _text (text)
, _cursor (0)
, _saved (0)
: _text {text}
{
}
@ -217,6 +215,7 @@ bool Pig::getDigits (int& result)
_cursor = prev;
break;
}
prev = _cursor;
}
@ -419,7 +418,7 @@ bool Pig::getOneOf (
const std::vector <std::string>& options,
std::string& found)
{
for (auto& option : options)
for (const auto& option : options)
{
if (skipLiteral (option))
{
@ -469,7 +468,7 @@ std::string Pig::peek (const int quantity) const
}
////////////////////////////////////////////////////////////////////////////////
std::string::size_type Pig::cursor ()
std::string::size_type Pig::cursor () const
{
return _cursor;
}

View file

@ -33,7 +33,7 @@
class Pig
{
public:
Pig (const std::string&);
explicit Pig (const std::string&);
bool skip (int);
bool skipN (const int quantity = 1);
@ -56,7 +56,7 @@ public:
bool eos () const;
int peek () const;
std::string peek (const int) const;
std::string::size_type cursor ();
std::string::size_type cursor () const;
std::string::size_type save ();
std::string::size_type restore ();
@ -64,8 +64,8 @@ public:
private:
const std::string& _text;
std::string::size_type _cursor;
std::string::size_type _saved;
std::string::size_type _cursor {0};
std::string::size_type _saved {0};
};
#endif