C++ Logo

std-proposals

Advanced search

No need for typename and template once it's stated in the concept

From: Михаил Найденов <mihailnajdenov_at_[hidden]>
Date: Thu, 6 Jan 2022 18:12:50 +0200
Hello,
The title says it all, consider:

template<class T>
concept stuff_as_members = requires {
  typename T::type;
  T::template templ<int>();
};

struct C
{
  using type = int;

  template<class T>
  static void templ() {}
};

template<stuff_as_members T> //< constrained type!
void func()
{
  T::type val; //< typename should NOT be needed, type is known to be a
typename

  T::templ<int>(); //< template should NOT be needed, templ is known to be
a template
}

int main()
{
  func<C>();
}

Can we do this for good?
Thank You

Received on 2022-01-06 10:13:05