2

Just want to confirm that type of templated variable can be independent of template. This compiles by g++:

template<class T> 
constexpr long MAX_AS_LONG = static_cast<long>(std::numeric_limits<T>::max());

Does it confirm to the standard?

(In all the examples on the internet, type of templated variable is T itself).

user2052436
  • 4,321
  • 1
  • 25
  • 46

1 Answers1

0

There is no requirement the type of a template variable differs based on template arguments.

A common example is std::is_same_v<T,U> which is always a bool.

Yakk - Adam Nevraumont
  • 262,606
  • 27
  • 330
  • 524