|
Boost : |
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2006-08-06 06:13:30
>> It would nice (just an idea) to have a way to execute an expression
>> for
>> every parameter, just like it was a function unrolling, implemented
>> with
>> with macros:
>>
>> template<typename... Values>
>> void push back all(const T& value, const Values&... values) {
>> std::variadic_unroll(push_back(value));
>> }
>>
>> Just an idea for the future. I don't know if implementing this is too
>> difficult. That would help with compilation time.
>
> Oh, you can do that already, if you don't mind turning that push_back
> call into a non-void expression:
>
> template<typename... Args>
> void variadic_unroll(const Args&...) { }
>
> template<typename... Values>
> void push_back_all(const Values&... values) {
> variadic_unroll((push_back(values), 0)...);
> }
Good. I can set the bar higher if you want ;-). What about storing the
return value in a tuple:
bool test()
{ /**/ }
template<typename... Values>
void test_all(const Values&... values) {
//Is this possible?
//tuple<decltype(test(Values))...> ret_tuple = ...
//or using "auto"
auto ret_tuple = variadic_unroll(test(values));
}
It would be also nice a way to define a tuple of N objects of the same
type: auto tup = make_tuple_n<bool, 6>;
And iterate at runtime in a tuple of N objects of the same type, to get
each value (the iterator would climb in the inheritance-emulation code
when incremeting it):
for( bool ok : ret_tuple )
std::cout << "return value:" << ok;
Keep up the good work!
Ion
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk