C++ Logo


Advanced search

[std-proposals] pass() replacement for: forward<>()

From: Phil Bouchard <boost_at_[hidden]>
Date: Thu, 5 Jan 2023 19:44:34 -0500

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 &&)


Email Signature
Logo <https://www.fornux.com/>  
*Phil Bouchard*  facebook icon 
T: (819) 328-4743
E: phil_at_[hidden]| www.fornux.com <http://www.fornux.com>
8 rue de la Baie| Gatineau (Qc), J8T 3H3 Canada
Banner <https://goglobalawards.org/> 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.

Received on 2023-01-06 00:44:35