Created
December 4, 2020 21:29
-
-
Save asit-dhal/7f0b2215c01ac5db4606b8cc84eb797a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
template<std::size_t idx> auto get(const B &b) | |
{ | |
static_assert (idx < 4); | |
if constexpr (idx == 0) { | |
return b.a; | |
} else if constexpr (idx == 1) { | |
return b.c; | |
} else if constexpr (idx == 2) { | |
return b.d; | |
} else { | |
return b.e; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment