Questions tagged [variable-templates]

Use this tag for anything related to C++14 variable templates.

Variable templates are a feature of C++ as of C++14. They allow variables to be declared as templates, just like functions and classes:

template<class T>
constexpr T pi = T(3.1415926535897932385);

template<class T>
    T circular_area(T r) {
    return pi<T> * r * r;
}
68 questions
1
vote
1 answer

how to create a variable-template?

#include using namespace std; template struct Power { static constexpr int a = base * (Power::a); }; template struct Power { static constexpr int a =…
mai brick
  • 25
  • 6
1
vote
1 answer

How to pass a variable template as template argument

I am aware, that I can pass a class template as template argument like this: template