1

The following code:

template<class S, class = void>
constexpr bool is_size = false;
template<class S>
constexpr bool is_size<S, std::void_t<decltype(S::cx, S::cy)>> = true;
template<class S>
constexpr bool is_size<S, std::void_t<decltype(S::width, S::height)>> = true;

gives

error : redefinition of 'is_size<S, std::void_t<decltype(S::width , S::height)>>'.

Is it possible to implement the idea somehow or the only thing that can be done is comparing with all size types?

Oleksa
  • 635
  • 5
  • 15
  • using `decltype(S::cx, S::cy, void())` instead of `std::void_t` please gcc/clang but not msvc [Demo](https://godbolt.org/z/3sfzYbWaG). – Jarod42 Jun 04 '21 at 10:18
  • `struct` with `decltype` pleases all compilers [Demo](https://godbolt.org/z/d5jsqdYTY). – Jarod42 Jun 04 '21 at 10:29
  • Not sure if you can do one template directly, but you can do two and combine them with `std::disjunction` – sklott Jun 04 '21 at 10:52
  • this might be clang bug [46791](https://bugs.llvm.org/show_bug.cgi?id=46791). Might want to report it to Microsoft, too (also the `void()` case). – rustyx Jun 04 '21 at 11:06

0 Answers0