2 thoughts on “Building, say, indices<6,4,2,0,-2,-4>”
> the select function can be typed just as effectively by the more ornate code below.
This is not true. That code is not correct in the general case. As a start, that implementation of select is not the best, but ignoring that for a moment, the second version does not always behave like the first one.
Thankyou, you are correct. I’m not so interested in reference arguments here, so I’ve simply updated the return type of the non-decltype version to also decay (using std::decay) the tuple elements. I’m actually quite pleased that it’s now more verbose, as it emphasises my preference here for the use of decltype. I’ve given stacked-crooked.com a whirl with my own test here.
> the select function can be typed just as effectively by the more ornate code below.
This is not true. That code is not correct in the general case. As a start, that implementation of select is not the best, but ignoring that for a moment, the second version does not always behave like the first one.
The assertions in this program hold: http://stacked-crooked.com/view?id=2383053c85152e4695364e32ce1688df. That actually means the second version does not compile in the presence of tuples references: http://stacked-crooked.com/view?id=8b4471beb5cd06a55853a04e9a483f4c. And there are other behaviours of the first version that the second version does not emulate, namely those concerning std::reference_wrapper.
Thankyou, you are correct. I’m not so interested in reference arguments here, so I’ve simply updated the return type of the non-
decltype
version to also decay (usingstd::decay
) the tuple elements. I’m actually quite pleased that it’s now more verbose, as it emphasises my preference here for the use ofdecltype
. I’ve given stacked-crooked.com a whirl with my own test here.