5

Does anyone know, if there exists a standards proposal for a c++ language feature that would allow me to replace this (thanks to Yakk):

template<class... ARGS>
void bar(const ARGS& ... args) {        
    auto t = { (foo(args),0)... };
    (void) t; //<- prevent warning about unused variable
}

with something more natural like this:

template<class... ARGS>
void bar(const ARGS& ... args) {        
    foo(args)...;
}

foo being e.g. a function, a function template and/or an overloaded set of those, whose return type might be void (or in general which I don't care about).

Btw, if someone knows a more concise way to write this in c++14, feel free to share, but I think, this is already handled in this question

Community
  • 1
  • 1
MikeMB
  • 20,029
  • 9
  • 57
  • 102

1 Answers1

7

Use a fold expression with the comma operator:

( void(foo(args)) , ...);

I didn't see any proposal to change this further in recent mailings.

T.C.
  • 133,968
  • 17
  • 288
  • 421
  • That is indeed a nice feature - has this already been voted into the next standard or is it only proposed? – MikeMB Jan 07 '16 at 18:54