for example there is such a template
template<class ... Types> void f(Types ... args);
f(); // OK: args contains no arguments
f(1); // OK: args contains one argument: int
f(2, 1.0); // OK: args contains two arguments: int and double
and I want to do so in it
template<class ... T>
void f2(T... args) {
// option 1
// > hello // world // human
std::cout <<(args / ...);
// option 2
// > hello // world
std::cout <<((args / ...) and -1 args); // ../
}
in the example, option 2
We are concatenating the Hello
and world
string and at the same time not using the human
, since we don't need it yet.
if it is possible of course
f2("hello", "world", "human");
then
get one less argument inside the function to use it inside the function
For this call:
f2("A", "b", 12);
Expected result should be equivalent to this:
std::cout << "A";
std::cout << "b";
// no statement or different action for: std::cout << 12;
and if possible without arrays and recursions
if there is no such functionality, then write that it is not there.
question from:
https://stackoverflow.com/questions/65935047/if-there-is-such-a-function-in-a-variadic-template 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…