#include <sstream>
namespace std
{
// This class exists solely to "trick" the compiler into
// considering this allocator a new, different type
class newallocator : public allocator<char>
{
};
// template specialize std::stringstream to inherit from basic_stringstream
// using our newallocator in place of std::allocator<char>
template <>
class basic_stringstream<char, char_traits<char>, allocator<char> >
: public basic_stringstream <char, char_traits<char>, newallocator >
{
public:
basic_stringstream()
{
precision(16); // or whatever precision you like
}
};
}
int main()
{
std::stringstream ss;
double d = 0.1234567890123456;
ss << d;
std::cout << ss.str() << std::endl;
}