# On boost, std and c++ standards

This topic is 4848 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, A couple of minutes ago I was reading a thread about converting an int to a const char* or something among those lines. Someone replied that the OP should use boost or std to do the conversion, as itoa() wasnt so standard as there were many different signatures for that function. My question is, where (online resources I would be most interested, but books should be ok as a last alternative) can I check if a given function is part of the standard, or is aimed to be really portable. From what I know, std and boost aim to do that, as well as the gcc compiler (which id the main reason I like it), but when I encounter a problem in which I could use many approaches as in the aforementioned thread, how do I know which one is the most standard one, or is this something you can only know by experience and in a per function basis (i.e theres no single resource website or book that can tell me this)? Thanks

##### Share on other sites
You mean other than MSDN?

##### Share on other sites
For the std library, the definitive resource is ISO14882 which is the C++ standard (you also need a copy of the C standard, as it's referenced in the C++ standard).

boost.org has all the info you need about boost.

Another good reference is MSDN. If a function isn't standard, it will usually be surrounded by 'Microsoft specific'/'End Microsoft specific' tags.

##### Share on other sites
Converting a char * to int (or vice versa) is nonsensical and you shouldn't do it.

If you mean, converting an int into a C-string using base-10 numbers, then of course that can be done, but it is not a cast of any sort, rather a distinct operation.

Yes, itoa will work. In the past I've used the following template function

using namespace std; // <-- don't do this if you put this in a headertemplate <typename T> string toString(T obj){        ostringstream oss;        oss << obj;        return oss.str();}

Which will work for any type which has an overload of <<

Mark

##### Share on other sites
Quote:
 Original post by markrConverting a char * to int (or vice versa) is nonsensical and you shouldn't do it.If you mean, converting an int into a C-string using base-10 numbers, then of course that can be done, but it is not a cast of any sort, rather a distinct operation.Yes, itoa will work. In the past I've used the following template function using namespace std; // <-- don't do this if you put this in a headertemplate string toString(T obj){ ostringstream oss; oss << obj; return oss.str();}Which will work for any type which has an overload of <

Oh no... I was just saying there was a thread in which the OP wanted to do such conversion, and then I asked myself about the c++ standards because of someone's reply to that thread.. hehe

##### Share on other sites
Also, the man pages for functions in the gcc world will also tell you if they're part of a standard (C, C++, POSIX, etc.) or an extension.

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 11
• 10
• 13
• 20
• ### Forum Statistics

• Total Topics
632948
• Total Posts
3009399
• ### Who's Online (See full list)

There are no registered users currently online

×