Skip to content

Instantly share code, notes, and snippets.

@uwanosorauepon
Last active April 1, 2020 15:29
Show Gist options
  • Save uwanosorauepon/b7767df4d5824b12c3a3ae6e1cec332f to your computer and use it in GitHub Desktop.
Save uwanosorauepon/b7767df4d5824b12c3a3ae6e1cec332f to your computer and use it in GitHub Desktop.
[C++] charを任意の文字型に変換する(コンパイル時)
// charを他の文字型に変換する
// T: (char|wchar_t|char8_t|char16_t|char32_t)
template <typename T>
constexpr T Convert(char c)
{
// リトルエンディアン、ビッグエンディアン関係なくこれで良さそう。
return static_cast<T>(c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment