Skip to content

Commit

Permalink
Fix #224: static_assert is_sorted(). (#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanTLavavej authored Jan 24, 2020
1 parent 10a2276 commit 616cbea
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions stl/src/winapinls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

#if _STL_WIN32_WINNT < _WIN32_WINNT_VISTA

#include <algorithm>
#include <ctype.h>
#include <stdlib.h>
#include <string_view>

namespace {
struct LCIDTOLOCALENAME {
Expand Down Expand Up @@ -255,6 +257,9 @@ namespace {
};
// clang-format on

static_assert(_STD is_sorted(_STD begin(LcidToLocaleNameTable), _STD end(LcidToLocaleNameTable),
[](const auto& left, const auto& right) { return left.lcid < right.lcid; }));

// Map of locale name to an index in LcidToLocaleNameTable, for Windows XP.
// Data in this table has been obtained from National Language Support (NLS) API Reference.
// The table is sorted to improve search performance.
Expand Down Expand Up @@ -490,6 +495,13 @@ namespace {
{ L"zu-za" , 112 },
};
// clang-format on

// This static_assert is case-sensitive, which is more than sufficient for the case-insensitive runtime lookups.
static_assert(_STD is_sorted(
_STD begin(LocaleNameToIndexTable), _STD end(LocaleNameToIndexTable), [](const auto& left, const auto& right) {
return _STD wstring_view{left.name} < _STD wstring_view{right.name};
}));

} // unnamed namespace

// __wcsnicmp_ascii
Expand Down

0 comments on commit 616cbea

Please sign in to comment.