Implement stream operator<< in terms of the faster to_string() method.
This commit is contained in:
parent
7a3e380c21
commit
b6f1515be5
@ -552,35 +552,7 @@ namespace uuids
|
|||||||
template <class Elem, class Traits>
|
template <class Elem, class Traits>
|
||||||
std::basic_ostream<Elem, Traits> & operator<<(std::basic_ostream<Elem, Traits> &s, uuid const & id)
|
std::basic_ostream<Elem, Traits> & operator<<(std::basic_ostream<Elem, Traits> &s, uuid const & id)
|
||||||
{
|
{
|
||||||
// save current flags
|
s << to_string(id);
|
||||||
std::ios_base::fmtflags f(s.flags());
|
|
||||||
|
|
||||||
// manipulate stream as needed
|
|
||||||
s << std::hex << std::setfill(static_cast<Elem>('0'))
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[0])
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[1])
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[2])
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[3])
|
|
||||||
<< '-'
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[4])
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[5])
|
|
||||||
<< '-'
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[6])
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[7])
|
|
||||||
<< '-'
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[8])
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[9])
|
|
||||||
<< '-'
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[10])
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[11])
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[12])
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[13])
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[14])
|
|
||||||
<< std::setw(2) << static_cast<int>(id.data[15]);
|
|
||||||
|
|
||||||
// restore original flags
|
|
||||||
s.flags(f);
|
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user