mirror of
https://github.com/AnthonyCalandra/modern-cpp-features.git
synced 2025-12-17 10:04:35 +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)
|
- [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
|
||||||
|
|||||||
Reference in New Issue
Block a user