I’m looking for template code to sort template arguments by the return value of their static member function static constexpr int getType()
, something like:
#include <iostream>
#include <type_traits>
class A {
public:
static constexpr int getType() { return 1; }
};
class B {
public:
static constexpr int getType() { return 2; }
};
class C {
public:
static constexpr int getType() { return 3; }
};
template <typename...T>
struct Sort { /*...*/ };
int main() {
using Sorted = Sort<C, A, B>::type; // std::tuple<A, B, C> or something like
std::cout << typeid(Sorted).name() << std::endl;
return 0;
}
Anyway, I want a typename sequence in ascending order in any form.