How can I enable perfect forwarding through a virtual function? I really have no desire to write every overload like in C++03.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t. Perfect forwarding only works by combining templates and rvalue-references, because it depends on what kind of real type
T&&evaluates to when T is specialized. You cannot mix templates and virtual functions.However, you can might be able to solve your problem by some kind of type-erasure mechanism: