Greetings,
Please find attached a small wrapper function that could be useful as a replacement for forward<>() which uses explicit type specification (for some reason), shorter to type and can be used as perfect forwarding for virtual functions as well, not only with template functions. You can use it for universal parameter types as well.
The attached
executable will output the following:
1) classic
foo(i):
void foo(T &&) [T = int &]
void bar(int &)
2) classic foo(9):
void foo(T &&) [T = int]
void bar(int &&)
3) classic a.foo(i): error
4) classic a.foo(9):
virtual void A::foo(int &&)
T &&pass(T &) [T = int]
void bar(int &&)
5) suggested a.foo(pass(i)):
T &&pass(T &) [T = int]
virtual void A::foo(int &&)
T &&pass(T &) [T = int]
void bar(int &&)
6) suggested a.foo(pass(9)):
T &&pass(T &&) [T = int]
virtual void A::foo(int &&)
T &&pass(T &) [T = int]
void bar(int &&)
Regards,
|
|
|||||||
Le message ci-dessus,
ainsi que les documents l'accompagnant, sont destinés
uniquement aux personnes identifiées et peuvent contenir
des informations privilégiées, confidentielles ou ne
pouvant être divulguées. Si vous avez reçu ce message par
erreur, veuillez le détruire.This communication (and/or the attachments) is intended for named recipients only and may contain privileged or confidential information which is not to be disclosed. If you received this communication by mistake please destroy all copies. |
||||||||