forked from OctaForge/libostd
keyset: allow get_key to return by value (still use reference where possible)
parent
50a8562d20
commit
4f23017594
|
@ -19,11 +19,17 @@ namespace ostd {
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using KeysetKey = const Decay<decltype(declval<const T &>().get_key())>;
|
using KeysetKeyRet = decltype(declval<const T &>().get_key());
|
||||||
|
template<typename T>
|
||||||
|
using KeysetKey = const Decay<KeysetKeyRet<T>>;
|
||||||
|
|
||||||
template<typename T, typename A> struct KeysetBase {
|
template<typename T, typename A> struct KeysetBase {
|
||||||
using Key = KeysetKey<T>;
|
using Key = KeysetKey<T>;
|
||||||
static inline const Key &get_key(const T &e) {
|
|
||||||
|
using RetKey = Conditional<
|
||||||
|
IsReference<KeysetKeyRet<T>>::value, Key &, Key
|
||||||
|
>;
|
||||||
|
static inline RetKey get_key(const T &e) {
|
||||||
return e.get_key();
|
return e.get_key();
|
||||||
}
|
}
|
||||||
static inline T &get_data(T &e) {
|
static inline T &get_data(T &e) {
|
||||||
|
|
Loading…
Reference in New Issue