[meta] Add hb_reference_wrapper<>
Functionality kinda superset of std:: counterpart.
This commit is contained in:
parent
0bf86d9c5d
commit
03a68165d8
|
@ -138,6 +138,27 @@ struct
|
||||||
|
|
||||||
} HB_FUNCOBJ (hb_ref);
|
} HB_FUNCOBJ (hb_ref);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct hb_reference_wrapper
|
||||||
|
{
|
||||||
|
hb_reference_wrapper (T v) : v (v) {}
|
||||||
|
hb_reference_wrapper (const hb_reference_wrapper& o) : v (o.v) {}
|
||||||
|
bool operator == (const hb_reference_wrapper& o) const { return v == o.v; }
|
||||||
|
bool operator != (const hb_reference_wrapper& o) const { return v != o.v; }
|
||||||
|
T get () const { return v; }
|
||||||
|
T v;
|
||||||
|
};
|
||||||
|
template <typename T>
|
||||||
|
struct hb_reference_wrapper<T&>
|
||||||
|
{
|
||||||
|
hb_reference_wrapper (T& v) : v (&v) {}
|
||||||
|
hb_reference_wrapper (const hb_reference_wrapper& o) : v (o.v) {}
|
||||||
|
bool operator == (const hb_reference_wrapper& o) const { return v == o.v; }
|
||||||
|
bool operator != (const hb_reference_wrapper& o) const { return v != o.v; }
|
||||||
|
T* get () const { return v; }
|
||||||
|
T* v;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
template <bool B, typename T = void> struct hb_enable_if {};
|
template <bool B, typename T = void> struct hb_enable_if {};
|
||||||
template <typename T> struct hb_enable_if<true, T> { typedef T type; };
|
template <typename T> struct hb_enable_if<true, T> { typedef T type; };
|
||||||
|
|
Loading…
Reference in New Issue