[llvm-dev] Need help with windows build error and std::to_string

Benjamin Kramer via llvm-dev llvm-dev at lists.llvm.org
Sat Nov 28 14:10:49 PST 2015


On Sat, Nov 28, 2015 at 11:03 PM, Diego Novillo <dnovillo at google.com> wrote:
> Thanks. I
>
> On Sat, Nov 28, 2015 at 11:44 AM, Benjamin Kramer <benny.kra at gmail.com>
> wrote:
>>
>> On Sat, Nov 28, 2015 at 5:14 PM, Diego Novillo via llvm-dev
>> <llvm-dev at lists.llvm.org> wrote:
>> >
>> > I need to build a Twine with a double value, so I was using
>> > std::to_string,
>> > but I'm getting "error: 'to_string' is not a member of 'std'" from a
>> > windows
>> > buildbot.  What's the canonical way to create a Twine() out of a double?
>>
>> via raw_ostream. Create a new raw_string_ostream or
>> raw_svector_ostream, << the double into it and take the string. I
>> don't think we have a more convenient way for that currently and
>> to_string is still not universally available.
>
>
> Thanks.  I suppose there's no easy way to format them?  I tried the standard
> io manipulators, but they don't seem to be supported in raw streams.  By
> default double values are emitted in scientific notation. I need to format
> them as percentage values.

OS << format("%.2f", foo), takes a printf format string.

- Ben


More information about the llvm-dev mailing list