mirror of
https://github.com/AnthonyCalandra/modern-cpp-features.git
synced 2025-12-17 01:54:36 +03:00
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:
11
README.md
11
README.md
@@ -34,6 +34,7 @@ C++14 includes the following new language features:
|
||||
- [return type deduction](#return-type-deduction)
|
||||
- [decltype(auto)](#decltypeauto)
|
||||
- [relaxing constraints on constexpr functions](#relaxing-constraints-on-constexpr-functions)
|
||||
- [variable templates](#variable-templates)
|
||||
|
||||
C++14 includes the following new library features:
|
||||
- [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
|
||||
```
|
||||
|
||||
### 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
|
||||
|
||||
### User-defined literals for standard library types
|
||||
|
||||
Reference in New Issue
Block a user