#include #include #include #include namespace karma = boost::spirit::karma; template struct my_policy : karma::real_policies { static unsigned int precision(T){return 3;} static int floatfield(T){return std::ios_base::scientific;} }; int main() { karma::real_generator > my_real; // Expected output is "1.0e01 1.0e-02 1.0e04" or "1.0e+01 1.0e-02 1.0e+04", // but result is "10.0e00 10.0e-03 10.0e03" std::cout << karma::format(my_real << " " << my_real << " " << my_real, 9.9999, 9.9996e-3, 9.99951e+3) << std::endl; }