TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24143 17
Template arity trait

I'm making a template arity trait, but cannot make it work on MSVC. The basic idea is to specialize the template below. It works fine on clang and g++, but MSVC fails to specialize the argument list (cf. https://godbolt.org/z/h9rGddzvz ). Any Idea how to achieve this ?

template <template <typename...> class C>
struct templatearity;

template <template <typename> class C>
struct template
arity<C> : std::integralconstant<std::sizet, 1> {};

I intended to use it in some static_asserts but can live without it.

https://redd.it/1ok81tr
@r_cpp
godbolt.org Compiler Explorer - C++ template <template <typename...> class C> struct template_arity; template <template <typename> class C> struct template_arity<C> : std::integral_constant<std::size_t, 1> {}; template <template <typename, typename> class C> struct template_arity<C> : st…
More from @r_cpp
  1. Oct 12, 2026[Release] slick-logger v2.2.0 — Lock-free asynchronous C++20 logging with multi-process sh…
  2. Oct 12, 2026Cheap alternative to reboot parameters (nohz, rcu, isolcpus) for stable benchmarks When no…
  3. Oct 12, 2026This C++ drama is crazy - Adobe votes no https://www.youtube.com/watch?v=DEqx_NMMH9Q https…
  4. Oct 12, 2026FastNoise2: noise generation using SIMD and C++17 https://github.com/Auburn/FastNoise2 htt…
  5. Oct 12, 2026New C++ Conference Videos Released This Month - October 2026 (Updated To Include Videos Re…
  6. Oct 12, 2026cxvm: pin a GCC or Clang version per project on Linux (pyenv/nvm, but for C++ compilers) I…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →