Merge pull request #23 from rickyviking/streamOperator

Stream << operator: restore original flags after streaming the uuid
This commit is contained in:
Marius Bancila 2020-09-09 23:14:44 +03:00 committed by GitHub
commit f08b54b88e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -541,7 +541,11 @@ namespace uuids
template <class Elem, class Traits>
std::basic_ostream<Elem, Traits> & operator<<(std::basic_ostream<Elem, Traits> &s, uuid const & id)
{
return s << std::hex << std::setfill(static_cast<Elem>('0'))
// save current flags
std::ios_base::fmtflags f(s.flags());
// manipulate stream as needed
s << std::hex << std::setfill(static_cast<Elem>('0'))
<< std::setw(2) << (int)id.data[0]
<< std::setw(2) << (int)id.data[1]
<< std::setw(2) << (int)id.data[2]
@ -562,6 +566,11 @@ namespace uuids
<< std::setw(2) << (int)id.data[13]
<< std::setw(2) << (int)id.data[14]
<< std::setw(2) << (int)id.data[15];
// restore original flags
s.flags(f);
return s;
}
template<class CharT = char,