Last active
May 18, 2017 03:07
-
-
Save thai-ng/1cdb47be696e0e3be421277626ed87af to your computer and use it in GitHub Desktop.
This file contains 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 <cstdio> | |
using namespace Platform; | |
void doTheThing(const wchar_t* string) | |
{ | |
printf("%ws\n", string); | |
} | |
template <typename T> | |
void CatTheThing(Platform::String^ str1, T str2) | |
{ | |
auto str = ref new Platform::String(str2); | |
CatTheThing(str1, str); | |
} | |
template <typename T> | |
void CatTheThing(T str1, Platform::String^ str2) | |
{ | |
auto str = ref new Platform::String(str1); | |
CatTheThing(str, str2); | |
} | |
void CatTheThing(Platform::String^ str1, Platform::String^ str2) | |
{ | |
doTheThing(Platform::String::Concat(str1, str2)->Data()); | |
} | |
int main() | |
{ | |
// two string literals, implicit conversion to Platform::String^ | |
CatTheThing(L"This", L"That"); | |
// 1 string literal, 1 Platform::String^ | |
auto str = L"this string though"; | |
auto str2 = ref new Platform::String(L"This other one"); | |
CatTheThing(str, str2); | |
// 1 string literal, 1 Platform::String^, reversed | |
CatTheThing(str, L"other"); | |
auto str3 = ref new Platform::String(L"Nuther one"); | |
// 2 Platform::String^ | |
CatTheThing(str2, str3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment