From 4f23017594734e9792bbcf205e1c61a2f32aa7c8 Mon Sep 17 00:00:00 2001 From: q66 Date: Wed, 5 Aug 2015 20:05:03 +0100 Subject: [PATCH] keyset: allow get_key to return by value (still use reference where possible) --- ostd/keyset.hh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ostd/keyset.hh b/ostd/keyset.hh index 6108f1d..0905efb 100644 --- a/ostd/keyset.hh +++ b/ostd/keyset.hh @@ -19,11 +19,17 @@ namespace ostd { namespace detail { template - using KeysetKey = const Decay().get_key())>; + using KeysetKeyRet = decltype(declval().get_key()); + template + using KeysetKey = const Decay>; template struct KeysetBase { using Key = KeysetKey; - static inline const Key &get_key(const T &e) { + + using RetKey = Conditional< + IsReference>::value, Key &, Key + >; + static inline RetKey get_key(const T &e) { return e.get_key(); } static inline T &get_data(T &e) {