Skip to content

Commit

Permalink
Eliminate shadowed variable warnings from gcc-7.2
Browse files Browse the repository at this point in the history
The gcc-7.2.0 compiler (and others) were giving shadowed variable warnings for this include file.  A simple renaming of a couple local variables eliminates the warnings.
  • Loading branch information
gsjaardema authored and vitaut committed May 4, 2019
1 parent 29c10fb commit 2414140
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions include/fmt/ostream.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ template <class Char> class formatbuf : public std::basic_streambuf<Char> {
buffer<Char>& buffer_;

public:
formatbuf(buffer<Char>& buffer) : buffer_(buffer) {}
formatbuf(buffer<Char>& buf) : buffer_(buf) {}

protected:
// The put-area is actually always empty. This makes the implementation
Expand Down Expand Up @@ -72,26 +72,26 @@ template <typename T, typename Char> class is_streamable {
// Write the content of buf to os.
template <typename Char>
void write(std::basic_ostream<Char>& os, buffer<Char>& buf) {
const Char* data = buf.data();
const Char* buf_data = buf.data();
typedef std::make_unsigned<std::streamsize>::type UnsignedStreamSize;
UnsignedStreamSize size = buf.size();
UnsignedStreamSize max_size =
internal::to_unsigned((std::numeric_limits<std::streamsize>::max)());
do {
UnsignedStreamSize n = size <= max_size ? size : max_size;
os.write(data, static_cast<std::streamsize>(n));
data += n;
os.write(buf_data, static_cast<std::streamsize>(n));
buf_data += n;
size -= n;
} while (size != 0);
}

template <typename Char, typename T>
void format_value(buffer<Char>& buffer, const T& value) {
internal::formatbuf<Char> format_buf(buffer);
void format_value(buffer<Char>& buf, const T& value) {
internal::formatbuf<Char> format_buf(buf);
std::basic_ostream<Char> output(&format_buf);
output.exceptions(std::ios_base::failbit | std::ios_base::badbit);
output << value;
buffer.resize(buffer.size());
buf.resize(buf.size());
}

// Formats an object of type T that has an overloaded ostream operator<<.
Expand Down

0 comments on commit 2414140

Please sign in to comment.