Last active
May 18, 2017 07:37
-
-
Save thai-ng/2b6acac96baf7e78fa7caca97701a2f5 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 <cstdio> | |
#include <type_traits> | |
using namespace Platform; | |
void doTheThing(const wchar_t* string) | |
{ | |
printf("%ws\n", string); | |
} | |
template <typename T1, typename T2> | |
void CatTheThing(const T1& t1, const T2& t2) | |
{ | |
if constexpr(std::is_same_v<T1, Platform::String^> && | |
std::is_same_v<T2, Platform::String^>) | |
{ | |
printf("PlatformString-PlatformString\n"); | |
doTheThing(Platform::String::Concat(t1, t2)->Data()); | |
} | |
else if constexpr(!std::is_same_v<T1, Platform::String^> && | |
std::is_same_v<T2, Platform::String^>) | |
{ | |
printf("T-PlatformString\n"); | |
doTheThing(Platform::String::Concat(ref new Platform::String(t1), t2)->Data()); | |
} | |
else if constexpr(std::is_same_v<T1, Platform::String^> && | |
!std::is_same_v<T2, Platform::String^>) | |
{ | |
printf("PlatformString-T\n"); | |
doTheThing(Platform::String::Concat(t1, ref new Platform::String(t2))->Data()); | |
} | |
else | |
{ | |
printf("T-T\n"); | |
doTheThing(Platform::String::Concat(ref new Platform::String(t1), ref new Platform::String(t2))->Data()); | |
} | |
} | |
int main(Platform::Array<Platform::String^>^) | |
{ | |
CatTheThing(L"RawString", L"RawString"); | |
auto str = L"RawString"; | |
auto str2 = ref new Platform::String(L"PlatformString"); | |
CatTheThing(str, str2); | |
CatTheThing(str2, L"RawString"); | |
auto str3 = ref new Platform::String(L"PlatformString"); | |
CatTheThing(str2, str3); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment