可変引数テンプレートの全てのパラメータを-1する

にっき(pseudo) - 簡単な練習


こんなのできたのか・・・

#include <type_traits>

template <int... Seq>
struct A {};

template <int... Seq>
struct B {
    typedef A<(Seq - 1)...> type; // 全てのパラメータを-1
};

int main()
{
    typedef B<3, 2, 1>::type type; // type : A<2, 1, 0>

    static_assert(std::is_same<type, A<2, 1, 0> >::value, "not same"); // OK
}