Add section about variable templates to C++14 list

As per N3651 and C++14, variables can now be templated.
This commit is contained in:
Tulio Leao
2017-04-09 16:08:33 -03:00
committed by GitHub
parent 102599050a
commit 0b28c24857

View File

@@ -34,6 +34,7 @@ C++14 includes the following new language features:
- [return type deduction](#return-type-deduction) - [return type deduction](#return-type-deduction)
- [decltype(auto)](#decltypeauto) - [decltype(auto)](#decltypeauto)
- [relaxing constraints on constexpr functions](#relaxing-constraints-on-constexpr-functions) - [relaxing constraints on constexpr functions](#relaxing-constraints-on-constexpr-functions)
- [variable templates](#variable-templates)
C++14 includes the following new library features: C++14 includes the following new library features:
- [user-defined literals for standard library types](#user-defined-literals-for-standard-library-types) - [user-defined literals for standard library types](#user-defined-literals-for-standard-library-types)
@@ -530,6 +531,16 @@ constexpr int factorial(int n) {
factorial(5); // == 120 factorial(5); // == 120
``` ```
### Variable Templates
C++14 allows variables to be templated:
```c++
template<class T>
constexpr T pi = T(3.1415926535897932385);
template<class T>
constexpr T e = T(2.7182818284590452353);
```
## C++14 Library Features ## C++14 Library Features
### User-defined literals for standard library types ### User-defined literals for standard library types