Is it possible to cout thread::id in a decimal or octal format?
std::cout << std::showbase;
cout << dec(or oct) << boost::this_thread::get_id()
I got always hex, for example 0xdf08.
You should be able to specify what output format you want by using standard I/O manipulators:
#include <iomanip>
// ...
std::cout << std::oct << boost::this_thread::get_id() << std::endl;
// ^^^^^^^^
// Octal
std::cout << std::dec << boost::this_thread::get_id() << std::endl;
// ^^^^^^^^
// Decimal
std::cout << std::hex << boost::this_thread::get_id() << std::endl;
// ^^^^^^^^
// Hexadecimal
However, notice that a thread::id
does not need to be a number. Also, it may be a number but may be printed to the standard output in a different way than just inserting that number into std::cout
.
The C++11 Standard specification the overload of operator <<
accepting an std::thread::id
(which I assume to behave similarly to Boost's correspondent overload for boost::thread::it
), says:
[...] Inserts an unspecified text representation of id into
out
.
This means the representation may not be a number at all, in which case formatting manipulators such as std::hex
,std::dec
, or std::oct
may not have any influence on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With