Created
March 12, 2019 09:57
-
-
Save Cleroth/246fa485ea1db6a930a72487fdec8609 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
struct OutArg { | |
T * operator ->() const | |
{ | |
return &_t; | |
} | |
T & operator*() const | |
{ | |
return _t; | |
} | |
operator T&() const | |
{ | |
return _t; | |
} | |
OutArg(T & t) : _t(t) {} | |
private: | |
T & _t; | |
OutArg(OutArg&) = delete; | |
}; | |
namespace detail { | |
struct OutArgConstructor | |
{ | |
template <typename T> | |
OutArg<T> & operator^(OutArg<T> & t) | |
{ | |
return t; | |
} | |
template <typename T> | |
OutArg<T> operator^(T & t) | |
{ | |
return OutArg(t); | |
} | |
}; | |
}; | |
#define out_ detail::OutArgConstructor{} ^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment