Skip to content

Instantly share code, notes, and snippets.

@btaczala
Created January 17, 2018 07:29
Show Gist options
  • Save btaczala/4c0e7a78126040a9f3843c4c5057b128 to your computer and use it in GitHub Desktop.
Save btaczala/4c0e7a78126040a9f3843c4c5057b128 to your computer and use it in GitHub Desktop.
#include <iostream>
template <std::size_t... Args>
struct IsSorted;
template <std::size_t index, std::size_t next, std::size_t... Args>
struct IsSorted<index, next, Args...> {
constexpr static const bool sorted =
index < next && IsSorted<next, Args...>::sorted;
};
template <std::size_t almostLast, std::size_t last>
struct IsSorted<almostLast, last> {
constexpr static const bool sorted = almostLast < last;
};
template <std::size_t... Args>
struct Numbers {
constexpr static const bool is_sorted = true;
};
int main(int argc, char *argv[]) { Numbers<1, 2, 3> nums; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment