12345678910111213141516171819202122232425262728293031323334353637 |
- #if 0
- g++ -Wall -std=c++03 -I/usr/local/include/tr1_fwd -o "$0.run" "$0"
- exit
- #endif
- /*
- * cxxomfort example: to_string
- *
- * This program provides sample usage of the
- * "to_string" backport feature.
- *
- */
- #include <cxxomfort/base.hpp>
- #include <cxxomfort/cstdio.hpp>
- #include <cxxomfort/string.hpp>
- #include <string>
- #include <iostream>
- #include <cstdlib>
- int main () {
- using namespace std;
- cxxomfort::output_info(); cout<< endl;
-
- cout<< "Next line should print '15' as we call to_string(int): "<< endl;
- cout<< to_string(15)<< endl;
- cout<< "Next line should print '0' as there is no to_string(bool): "<< endl;
- cout<< to_string(false)<< endl;
- cout<< "Next we invoke to_string for an int, a short and a long: "<< endl;
- cout<< to_string(int(1))<< " "<< to_string(short(-1))<< " "<< to_string(long(-2))<< endl;
- cout<< "Next line should print something like '15.152000' as we call to_string(floating_point): "<< endl;
- cout<< to_string(15.152)<< endl;
- cout<< "Next line should print '63', the dec value of 0x3f, as we can't pass 'hex <<' to the formatting: "<< endl;
- cout<< to_string(0x3f)<< endl;
- return 0;
-
- }
|