Skip to content

Commit

Permalink
Check the list is sorted during compilation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hana Dusíková committed Aug 7, 2020
1 parent e22de94 commit 503d993
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/fileformat/file_format/pe/pe_dll_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4086,6 +4086,27 @@ constexpr static std::string_view defDllList[] = {
"ztrace_maps.dll",
};


// utility to check the list is really sorted (I can't use C++ algorithms here, as C++17 doesn't have constexpr version of these)
template <typename T> constexpr bool isSorted(T && arr) {
auto first = std::begin(arr);
auto last = std::end(arr);

if (first != last) {
auto next = first;
while (++next != last) {
if (std::less{}(*next, *first)) {
return false;
}
first = next;
}
}
return true;
}

static_assert(isSorted(defDllList), "The List of DLLs must be sorted!");


namespace retdec {
namespace fileformat {

Expand Down

0 comments on commit 503d993

Please sign in to comment.