mirror of
https://github.com/AnthonyCalandra/modern-cpp-features.git
synced 2025-12-17 10:04:35 +03:00
Fix incorrect (ill-formed) example for class template argument deduction
This commit is contained in:
@@ -75,14 +75,15 @@ C++11 includes the following new library features:
|
||||
### Template argument deduction for class templates
|
||||
Automatic template argument deduction much like how it's done for functions, but now including class constructors.
|
||||
```c++
|
||||
template <typename T>
|
||||
template <typename T = float>
|
||||
struct MyContainer {
|
||||
T val;
|
||||
MyContainer() : val() {}
|
||||
MyContainer(T val) : val(val) {}
|
||||
// ...
|
||||
};
|
||||
MyContainer c1{ 1 }; // OK MyContainer<int>
|
||||
MyContainer c2; // OK MyContainer<>
|
||||
MyContainer c2; // OK MyContainer<float>
|
||||
```
|
||||
|
||||
### Declaring non-type template parameters with auto
|
||||
|
||||
Reference in New Issue
Block a user