samedi 29 août 2020

How to choose type from some different on compilation time?

I want to do something like this:

template <uint64_t N>
struct a {
  static constexpr T1 v1 = {};
  static constexpr T2 v2 = {};
  static constexpr auto v3 = (N % 2 == 1 ? v1 : v2);
};

But I can't use (? :) with different types. How I can do this?

Aucun commentaire:

Enregistrer un commentaire