Merge pull request #3 from zygoloid/patch-1

Fix incorrect (ill-formed) example for class template argument deduction
This commit is contained in:
Anthony Calandra
2016-11-11 17:00:58 -08:00
committed by GitHub

View File

@@ -75,14 +75,15 @@ C++11 includes the following new library features:
### Template argument deduction for class templates ### Template argument deduction for class templates
Automatic template argument deduction much like how it's done for functions, but now including class constructors. Automatic template argument deduction much like how it's done for functions, but now including class constructors.
```c++ ```c++
template <typename T> template <typename T = float>
struct MyContainer { struct MyContainer {
T val; T val;
MyContainer() : val() {}
MyContainer(T val) : val(val) {} MyContainer(T val) : val(val) {}
// ... // ...
}; };
MyContainer c1{ 1 }; // OK MyContainer<int> MyContainer c1{ 1 }; // OK MyContainer<int>
MyContainer c2; // OK MyContainer<> MyContainer c2; // OK MyContainer<float>
``` ```
### Declaring non-type template parameters with auto ### Declaring non-type template parameters with auto