Starting with C ++ 14, std::tuple accepts constexpr std::get
#include <tuple> int main() { constexpr std::tuple<int, int, int> t { 1, 2, 3 }; static_assert(std::get<0>(t) == 1, ""); }
Live example
Similarly, you can use std::array also with std::get (as well as operator[] now constexpr ). You can also execute RC arrays.
#include <array> int main() { constexpr std::array<int, 3> a {{ 1, 2, 3 }}; static_assert(std::get<0>(a) == 1, ""); static_assert(a[0] == 1, ""); }
Live example
source share