Skip to content

Instantly share code, notes, and snippets.

@rileylev
Created July 6, 2020 22:21
Show Gist options
  • Save rileylev/22eb94a9919786dd7f3c8dc569b9b7dd to your computer and use it in GitHub Desktop.
Save rileylev/22eb94a9919786dd7f3c8dc569b9b7dd to your computer and use it in GitHub Desktop.
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