0

I'm trying to remove the first element of a variadic template argument. The code goes like this:

template<typename ...T> auto UniversalHook(T... args) { //I want to remove the first element of `args` here, how can I do that? CallToOtherFunction(std::forward<T>(args)...); } 

2 Answers 2

4

How about trying the direct approach.

template<typename IgnoreMe, typename ...T> auto UniversalHook(IgnoreMe && iamignored, T && ...args) { //I want to remove the first element of `args` here, how can I do that? return CallToOtherFunction(std::forward<T>(args)...); } 

(also fixed to use forwarding references, and added the obvious return )

Sign up to request clarification or add additional context in comments.

1 Comment

I forgot to mention, that I cant modify the Arguments of the Function, also the return Type is not needed, because the function can also have no return type. Thanks for your reply tho! Also I just got help from some other dude and he gave me some working code.
0

I just got a little help, and found the solution:

int main() { Function(3,5,7); return 0; } template<typename ...T> auto CallToAnotherFunction(T&&... args) { (cout << ... << args); } template<typename ...T> auto Function(T&&... args) { /*Return is not needed here*/return [](auto&& /*first*/, auto&&... args_){ return CallToAnotherFunction(std::forward<decltype(args_)>(args_)...); }(std::forward<T>(args)...); } //Output is "57" 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.