How can I use std :: hex for my custom uint128 type?

What is the correct syntax for overloading (or something really) std::hex so that its functionality can be extended to non-standard integers? I wrote this version of uint128_t

+7
source share
1 answer

std :: hex is just a manipulator that sets some formatting flags in a stream. You can get them using ios_base :: flags () and use the result in your <<statement. You should probably also use ios_base :: width and ios_base :: precision.

If you need more settings than provided, ios_base :: xalloc, ios_base :: iword, ios_base :: pword provide a path to extensions for your manipulators and inserts.

+8
source

All Articles