Micha Wiedenmann
Micha Wiedenmann

Reputation: 20843

Is decltype's result for template parameters

Is the result of decltype the same as the template identifier? (And what is the correct term when referring to T and its value?). That is are there cases where the assert fails?

template<typename T>
void foo(T x)
{
  static_assert(std::is_same<decltype(x), T>::value, "decltype check failed");
}

Upvotes: 0

Views: 72

Answers (1)

BЈовић
BЈовић

Reputation: 64223

Type of the variable x is T, therefore that static_assert is always going to pass.

Upvotes: 1

Related Questions