I have a tuple of unknown size (it\'s template parametr of method)
Is it way to get part of it (I need throw away first element of it)
For example, I have
Please don't use!
int
but may fail for your type!).See comments for discussion. I'm leaving this answer just for reference.
Even simpler:
tuple origin{7,12,42};
tuple &tail1 = (tuple&)origin;
tuple &tail2 = (tuple&)origin;
cout << "tail1: {" << get<0>(tail1) << ", " << get<1>(tail1) << "}" << endl;
cout << "tail2: {" << get<0>(tail2) << "}" << endl;
I got:
tail1: {12, 42}
tail2: {42}
I'm not certain that this is not an unspecified behaviour. Works for me: Fedora 20 and
❯ clang --version
clang version 3.3 (tags/RELEASE_33/final)
Target: x86_64-redhat-linux-gnu
Thread model: posix
❯ gcc --version
gcc (GCC) 4.8.2 20131212 (Red Hat 4.8.2-7)
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
References: article on voidnish.wordpress.com/.