Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Deducing this, i wish: my current approach just uses a macro to stamp out all the required overloads. The quadruplication is code-generated.
#include <utility>
#define FORALL_CONSTREFS(mac) \
mac(const, &, ) mac(, &, ) mac(, &&, std::move) mac(const, &&, std::move)
class ExampleIntWrapper {
public:
# define OVERLOADS_PLEASE(const_, ref_, move_) \
int const_ ref_ data() const_ ref_ { return move_(data_); }
FORALL_CONSTREFS(OVERLOADS_PLEASE)
private:
int data_;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment