Created
July 24, 2017 03:23
-
-
Save wengxt/396f0ccec920ead68c98c7a63c8d81a0 to your computer and use it in GitHub Desktop.
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 characters
#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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment