mirror of
https://github.com/AnthonyCalandra/modern-cpp-features.git
synced 2025-12-17 18:14:36 +03:00
Add definition of my_integer_sequence.
This commit is contained in:
@@ -100,6 +100,11 @@ MyContainer c2; // OK MyContainer<float>
|
|||||||
### Declaring non-type template parameters with auto
|
### Declaring non-type template parameters with auto
|
||||||
Following the deduction rules of `auto`, while respecting the non-type template parameter list of allowable types[\*], template arguments can be deduced from the types of its arguments:
|
Following the deduction rules of `auto`, while respecting the non-type template parameter list of allowable types[\*], template arguments can be deduced from the types of its arguments:
|
||||||
```c++
|
```c++
|
||||||
|
template <auto ... seq>
|
||||||
|
struct my_integer_sequence {
|
||||||
|
// Implementation here ...
|
||||||
|
};
|
||||||
|
|
||||||
// Explicitly pass type `int` as template argument.
|
// Explicitly pass type `int` as template argument.
|
||||||
auto seq = std::integer_sequence<int, 0, 1, 2>();
|
auto seq = std::integer_sequence<int, 0, 1, 2>();
|
||||||
// Type is deduced to be `int`.
|
// Type is deduced to be `int`.
|
||||||
|
|||||||
Reference in New Issue
Block a user