OSDN Git Service

245b0aa9a8304f969d6ea972ca35654bf3474847
[gintenlib/gintenlib.git] / gintenlib / to_string.hpp
1 #ifndef GINTENLIB_INCLUDED_TO_STRING_HPP_
2 #define GINTENLIB_INCLUDED_TO_STRING_HPP_
3
4 /*
5
6       <gintenlib/to_string.hpp>
7
8   to_string ¡§ Ê¸»úÎóÊÑ´¹
9   
10   Àë¸À¡§
11     template<typename T>
12     std::string to_str( const T& src );
13     template<typename T>
14     std::string to_string( const T& src );
15
16   µ¡Ç½¡§
17     Ê¸»úÎó¤ËÊÑ´¹¤¹¤ë¡£
18     lexical_cast¤è¤ê¡Ê¤¿¤Ö¤ó¡Ë¹â®
19
20 */
21
22 #include <string>
23 #include <sstream>
24
25 namespace gintenlib
26 {
27   template<typename T>
28   inline std::string to_string( const T& src )
29   {
30     // ½èÍý¤â¸«¤¿¤Þ¤Þ¤Ç¤¢¤ë
31     std::ostringstream oss;
32     oss << src;
33     
34     return oss.str();
35   }
36   template<typename T>
37   inline std::string to_str( const T& src )
38   {
39     // ¤µ¤é¤Ë̾Á°¤òû½Ì¤¹¤ë
40     std::ostringstream oss;
41     oss << src;
42     
43     return oss.str();
44   }
45
46 }   // namespace gintenlib
47
48
49 #endif  // #ifndef GINTENLIB_INCLUDED_TO_STRING_HPP_