7 #include "core/adt/hash.h"
24 T *Get()
const {
return inst_; }
25 T *operator->()
const {
return inst_; }
26 T &operator*()
const {
return *
inst_; }
28 unsigned Index()
const {
return index_; }
30 template <
typename U = T>
31 typename std::enable_if<std::is_base_of<Inst, U>::value, Type>::type
37 operator bool()
const {
return inst_ !=
nullptr; }
46 return !(*
this == that);
71 ,
class =
typename std::enable_if<std::is_base_of<U, T>::value>::type
92 ,
class =
typename std::enable_if<std::is_base_of<U, T>::value>::type
96 return {
static_cast<const U *
>(this->
inst_), this->
index_};
104 struct std::hash<
Ref<T>> {
105 std::size_t operator()(
const Ref<T> &ref)
const
108 ::hash_combine(hash, ref.Get());
109 ::hash_combine(hash, ref.Index());
119 std::size_t operator()(
const ConstRef<T> &ref)
const
122 ::hash_combine(hash, ref.Get());
123 ::hash_combine(hash, ref.Index());