Skip to content

Instantly share code, notes, and snippets.

@pookjw
Created September 6, 2023 15:18
Show Gist options
  • Save pookjw/9a4ad597a8bef279df016f658af58378 to your computer and use it in GitHub Desktop.
Save pookjw/9a4ad597a8bef279df016f658af58378 to your computer and use it in GitHub Desktop.
#import <concepts>
#import <functional>
template<class _Tp>
concept hashable = requires {
std::hash<_Tp>();
};
template <class T> requires std::equality_comparable<T> && std::copyable<T> && hashable<T>
class IdentifiableRef {
public:
IdentifiableRef(const T value) : value(value) {};
IdentifiableRef(const IdentifiableRef &other) {
this->value == other.value;
}
IdentifiableRef& operator=(const IdentifiableRef &other) {
this->value = other.value;
}
bool operator==(const IdentifiableRef& other) const {
return this->value == other.value;
}
const T value;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment