Created
February 18, 2020 17:01
-
-
Save juliusHuelsmann/388de17e534790e8d97e19023466f02b to your computer and use it in GitHub Desktop.
This snipplet shows how to make use of an index sequence when confined to structs, using the same principle exploited in #untuple.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Author: Julius Hülsmann | |
// Email: juliusHuelsmann [at] gmail.com, julius.huelsmann [at] data-spree.com | |
// Creation Date: 2020-02-18 | |
// Execution: g++-10.0 -std=c++2a indexSequence.cc | |
// This snipplet shows how to make use of an index sequence when confined to structs, using the | |
// same principle exploited in #untuple.cc | |
#include <cstdint> | |
#include <tuple> | |
template <std::size_t s, typename is = decltype(std::make_index_sequence<s>())> struct example; | |
template <std::size_t s, std::size_t... values> struct example<s, std::index_sequence<values...>> { | |
using t = int;// expand the std::size_t :) | |
}; | |
int main() { | |
example<5>::t k = 2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment