Remove sentry check in ArgumentParser::operator<<

cppcheck reports "Variable 'sen' is assigned a value that is never used.
[unreadVariable]" for this line.

As far as I understand, std::ostream::sentry is used to prepare access to
the stream buffer.  But, we are never directly accessing the stream
buffer.  Stream access in this function uses other operator<< functions.

Most noise in this patch is about unindenting after if() removal.

Signed-off-by: Sean Robinson <sean.robinson@scottsdalecc.edu>
This commit is contained in:
Sean Robinson 2021-11-10 13:54:35 -07:00
parent abb2206141
commit c0bbcf613c

View File

@ -1002,7 +1002,6 @@ public:
// Print help message // Print help message
friend auto operator<<(std::ostream &stream, const ArgumentParser &parser) friend auto operator<<(std::ostream &stream, const ArgumentParser &parser)
-> std::ostream & { -> std::ostream & {
if (auto sen = std::ostream::sentry(stream)) {
stream.setf(std::ios_base::left); stream.setf(std::ios_base::left);
stream << "Usage: " << parser.mProgramName << " [options] "; stream << "Usage: " << parser.mProgramName << " [options] ";
std::size_t tLongestArgumentLength = parser.get_length_of_longest_argument(); std::size_t tLongestArgumentLength = parser.get_length_of_longest_argument();
@ -1034,7 +1033,6 @@ public:
if (!parser.mEpilog.empty()) if (!parser.mEpilog.empty())
stream << parser.mEpilog << "\n\n"; stream << parser.mEpilog << "\n\n";
}
return stream; return stream;
} }