From 0b28c2485740c85f824975d594539fda32513e00 Mon Sep 17 00:00:00 2001 From: Tulio Leao Date: Sun, 9 Apr 2017 16:08:33 -0300 Subject: [PATCH] Add section about variable templates to C++14 list As per N3651 and C++14, variables can now be templated. --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 53ebfa8..c88b0ae 100644 --- a/README.md +++ b/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 +constexpr T pi = T(3.1415926535897932385); +template +constexpr T e = T(2.7182818284590452353); +``` + ## C++14 Library Features ### User-defined literals for standard library types