Last active
November 28, 2016 00:26
-
-
Save picanumber/bba2339c5648b53355487cd97d2b70f7 to your computer and use it in GitHub Desktop.
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
int main() | |
{ | |
int i1(1), i2(1); | |
char c1('o'), c2('k'); | |
auto tp{ std::make_tuple(2., 4., 23, 7, 'x', 'l') }; | |
std::array<char, 4> ar{ { 'a', 'b', 'c', 'd' } }; | |
// 1. read from a slice ----------------------------------- | |
std::tie(i1, i2) = tuple_slice<2, 4>(tp); | |
// 2. assign to a slice ----------------------------------- | |
tuple_slice<0, 2>(ar) = std::tie(c1, c2); | |
// 3. apply a slice on a lambda --------------------------- | |
std::apply([](auto&& arg1, auto&& arg2) { | |
std::cout << "(" << arg1 << ", " << arg2 << ")\n"; | |
}, tuple_slice<1, 3>(ar)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment