XIEITE_FWD ()
, XIEITE_FWD_PRVALUE ()
, XIEITE_FWD_PRVALUE_LOCAL ()
Defined in header <xieite/fwd.hpp>
(header-only:
<xieite/pp/fwd.hpp>
)
Replacements for
std ::forward
.Definitions
#0Functions exactly like#define XIEITE_FWD (...)static_cast <decltype (__VA_ARGS__ )&& >(__VA_ARGS__ )
std ::forward
without requiring a template argument.#1
Based on #0, but includes special cases:#define XIEITE_FWD_PRVALUE (...)/* ... */
- Does nothing with prvalues:
std ::same_as <decltype (XIEITE_FWD_PRVALUE (0 )), int >
- Avoids pessimization through temporary materialization (see example)
- Does nothing with lambda expressions:
XIEITE_FWD_PRVALUE ([] {})
Internally uses a lambda with no capture-default.
#2
Same functionality as #1, but internally uses a lambda with a reference capture-default.#define XIEITE_FWD_PRVALUE_LOCAL (...)/* ... */
Example
Possible output:#include <xieite/fwd.hpp> import std ;struct S {S () {std ::println (__PRETTY_FUNCTION__ ); }S (const S & ) {std ::println (__PRETTY_FUNCTION__ ); }S (S && ) {std ::println (__PRETTY_FUNCTION__ ); }~S () {std ::println (__PRETTY_FUNCTION__ ); }S & operator =(const S & ) {std ::println (__PRETTY_FUNCTION__ );return *this ; }S & operator =(S && ) {std ::println (__PRETTY_FUNCTION__ );return *this ; } };int main () { {S s =std ::forward <S >(S ()); }std ::"==================== ); {\n "S s =XIEITE_FWD_PRVALUE (S ()); } }
S::S() S::S(S&&) S::~S() S::~S() ==================== S::S() S::~S()