Created
July 24, 2017 03:23
-
-
Save wengxt/396f0ccec920ead68c98c7a63c8d81a0 to your computer and use it in GitHub Desktop.
Revisions
-
wengxt renamed this gist
Jul 24, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
wengxt created this gist
Jul 24, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ #include <fcitx-utils/metastring.h> #include <iostream> template<int b> class ItoA2 { public: using cur = typename ItoA2<b % 10>::type; using remain = typename ItoA2<b / 10>::type; using type = typename fcitx::ConcatMetaString<remain, cur>::type; }; #define ITOA2_DEF(N) template<> class ItoA2<N> { public: using type = fcitx::MetaString<N + '0'>; }; ITOA2_DEF(0); ITOA2_DEF(1); ITOA2_DEF(2); ITOA2_DEF(3); ITOA2_DEF(4); ITOA2_DEF(5); ITOA2_DEF(6); ITOA2_DEF(7); ITOA2_DEF(8); ITOA2_DEF(9); int main() { ItoA2<1234215>::type b; std::cout << b.data() << std::endl; return 0; }