From 73a1619cb74c83e0f6ca1b2b09824bceb9554685 Mon Sep 17 00:00:00 2001 From: cheny Date: Thu, 13 Jul 2017 19:20:57 +0800 Subject: [PATCH] Specialize map_compare for wchar_t (#44) Add the template partial specialization: struct map_compare {...} --- enum.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/enum.h b/enum.h index d423eef..edd92a0 100644 --- a/enum.h +++ b/enum.h @@ -1150,6 +1150,23 @@ struct map_compare { } }; +// chenyao add +template <> +struct map_compare { + BETTER_ENUMS_CONSTEXPR_ static bool less(const wchar_t *a, const wchar_t *b) + { return less_loop(a, b); } + + private: + BETTER_ENUMS_CONSTEXPR_ static bool + less_loop(const wchar_t *a, const wchar_t *b, size_t index = 0) + { + return + a[index] != b[index] ? a[index] < b[index] : + a[index] == L'\0' ? false : + less_loop(a, b, index + 1); + } +}; + template > struct map { typedef T (*function)(Enum);