to_string
语法:
1 |
?? string to_string(); |
to_string()函数返回bitset的字符串形式。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
//源代码 ??? /** ????? *? @brief Retuns a character interpretation of the %bitset. ????? *? @return? The string equivalent of the bits. ????? * ????? *? Note the ordering of the bits:? decreasing character positions ????? *? correspond to increasing bit positions (see the main class notes for ????? *? an example). ????? * ????? *? Also note that you must specify the string's template parameters ????? *? explicitly.? Given a bitset @c bs and a string @s: ????? *? @code ????? *???? s = bs.to_string<char,char_traits<char>,allocator<char> >(); ????? *? @endcode ???? */ ???? template<class _CharT, class _Traits, class _Alloc> ?????? basic_string<_CharT, _Traits, _Alloc> ?????? to_string() const ?????? { ???? basic_string<_CharT, _Traits, _Alloc> __result; ???? _M_copy_to_string(__result); ???? return __result; ?????? } |
测试代码:
测试结果:
10000010
10000100
请按任意键继续. . .
《Bitset类to_string函数运用》上有2条评论
评论已关闭。