例如,我可以使用std::ostream十六进制的对象输出整数
std::cout << std::hex << 0xabc; //prints `abc`, not the base-10 representation
Run Code Online (Sandbox Code Playgroud)
所有基地都有通用的操纵器吗?就像是
std::cout << std::base(4) << 20; //I want this to output 110
Run Code Online (Sandbox Code Playgroud)
如果有,那我就没有其他问题了.如果没有,那我可以写一个吗?它不会要求我访问私人实施细节std::ostream吗?
请注意,我知道我可以编写一个带有数字的函数,并将其转换为字符串,该字符串是任何基数中该数字的表示.或者我可以使用已经存在的.我问的是自定义流操纵器 - 它们可能吗?
提前致谢