[LLVMdev] Integer to string

Howard Hinnant hhinnant at apple.com
Wed Oct 12 07:54:12 PDT 2011

On Oct 12, 2011, at 8:18 AM, Pablo Barrio wrote:

> Hi,
> I need to convert an integer into a string. I would normally do that in C++ by using the StringStream class, but the LLVM coding standards discourage using that class. The same coding standards suggest to use llvm:StringStream instead, but I cannot find that class anywhere; furthermore, the header file where it was supposed to be (according to the coding standards) doesn't even exist.
> Is there any LLVM-native way to do that?
> What I want to do is to replicate a function several times and append a sequence number to each replica's name.
> Thanks ahead,
> Pablo

This doesn't really answer your question.  Instead I offer information to the llvm community:  C++ 11 offers these new functions in <string>:

string to_string(int val);
string to_string(unsigned val);
string to_string(long val);
string to_string(unsigned long val);
string to_string(long long val);
string to_string(unsigned long long val);
string to_string(float val);
string to_string(double val);
string to_string(long double val);

The only place I know of in current use where they are not implemented is Apple's v4.2 libstdc++.  I believe they've been in gcc and VC++ for several years.  They are also in libc++.


More information about the llvm-dev mailing list