Introduction to Variable Templates of C++14
zyxsh 270007JKVD Visits (21650)
The variable template, which comes from N3651, is one of the major proposals in Standard C++14. The main purpose of the variable template is to simplify definitions and uses of parameterized constants. 
Rules before C++14 do not allow declaring a variable using a template declaration. There are workarounds for this problem before C++14, but they are either redundant or complicated.
The first workaround is constexpr static data members of class templates as shown in Code 1. However, duplicate declarations are required: one inside the class template and another one outside the class template, which provides the real definition in case the constant is ODR (One Definition Rule) used.
The second workaround is constexpr function templates as shown in Code 2, which returns the desired values.
Now with variable templates of C++14, manipulation of constant values with various types can be significantly simplifiedas demonstrated in the most frequently used example -- PI<T>. PI is declared as a variable template, and given a constant value 3.14
At last, let’s have a look at what will happen when applying templates to non-constant variables. In Code 4, for example, when assigning a different value, 0.618, to PI<float>, PI<double> is not changed. It is not difficult to understand because the variable follows the rules of templates that initialize the instance for each use.
 Gabriel Dos Reis, N3651 Variable Templates, Revision 1, C++14 proposal, 2013.
 Chandra Shekhar Kumar, C++14 FAQs,2015.
English Editor: Jia Lei Ma (Yvonne). Many thanks for Yvonne’s help !