aboutsummaryrefslogtreecommitdiff
path: root/lib/util.h
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-08 10:52:57 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-07-08 10:58:24 +0900
commitf86f5272c27b4af1037045482135480a4bac3cd4 (patch)
tree5ef449beb39d9ecb7bc375d65c3cdd23bf4b2b5b /lib/util.h
parent24578e84ea325456c5635ec7ac46f9a818d3befe (diff)
downloadlibquotient-f86f5272c27b4af1037045482135480a4bac3cd4.tar.gz
libquotient-f86f5272c27b4af1037045482135480a4bac3cd4.zip
Omittable: support perfect forwarding
Diffstat (limited to 'lib/util.h')
-rw-r--r--lib/util.h15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/util.h b/lib/util.h
index aa44893f..4fdf7aa0 100644
--- a/lib/util.h
+++ b/lib/util.h
@@ -77,17 +77,12 @@ namespace QMatrixClient
public:
explicit Omittable() : Omittable(none) { }
Omittable(NoneTag) : _omitted(true) { }
- Omittable(const T& val) : _value(val) { }
- Omittable(T&& val) : _value(std::move(val)) { }
- Omittable<T>& operator=(const T& val)
+ template <typename TT>
+ Omittable(TT&& val) : _value(std::forward<TT>(val)) { }
+ template <typename TT>
+ Omittable<T>& operator=(TT& val)
{
- _value = val;
- _omitted = false;
- return *this;
- }
- Omittable<T>& operator=(T&& val)
- {
- _value = std::move(val);
+ _value = std::forward<TT>(val);
_omitted = false;
return *this;
}