diff --git a/README.md b/README.md index 48df5de..a195932 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,7 @@ C++14 includes the following new language features: C++14 includes the following new library features: - [user-defined literals for standard library types](#user-defined-literals-for-standard-library-types) +- [compile-time integer sequences](#compile---time-integer-sequences) ## C++17 Language Features @@ -436,6 +437,24 @@ day.count(); // == 24 std::chrono::duration_cast(day).count(); // == 1440 ``` +### Compile-time integer sequences +The class template `std::integer_sequence` represents a compile-time sequence of integers. There are a few helpers built on top: +* `std::make_integer_sequence` - creates a sequence of `0, ..., N - 1` with type `T`. +* `std::index_sequence_for` - converts a template parameter pack into an integer sequence. + +Convert an array into a tuple: +```c++ +template +decltype(auto) a2t_impl(const Array& a, std::integer_sequence) { + return std::make_tuple(a[I]...); +} + +template> +decltype(auto) a2t(const std::array& a) { + return a2t_impl(a, Indices()); +} +``` + ## C++11 Language Features TODO