linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #05784
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2965: simplify getset
------------------------------------------------------------
revno: 2965
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Mon 2012-06-25 21:18:57 +0200
message:
simplify getset
modified:
dcpp/GetSet.h
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/GetSet.h'
--- dcpp/GetSet.h 2012-06-18 15:56:01 +0000
+++ dcpp/GetSet.h 2012-06-25 19:18:57 +0000
@@ -19,18 +19,8 @@
#ifndef DCPLUSPLUS_DCPP_GET_SET_H
#define DCPLUSPLUS_DCPP_GET_SET_H
-/* adds a private member variable to a class and provides public member functions to access it:
-
- - for small types, one getter function that retrieves a copy of the member variable.
- - for small types, one setter function that assigns a copy of the value passed as parameter to
- the member variable.
-
- - for large types, one getter function that retrieves a const reference to the member variable.
- - for large types, two setter functions:
- * one setter function that binds to non-const rvalue references and moves the rvalue to the
- member variable (no copy operation).
- * one setter function that binds to the rest and assigns a copy of the value passed as
- parameter to the member variable. */
+/* adds a private member variable to a class and provides public get & set member functions to
+access it. */
#include <type_traits>
@@ -39,15 +29,7 @@
#define GETSET(t, name, name2) \
private: t name; \
public: std::conditional<std::is_class<t>::value, const t&, t>::type get##name2() const { return name; } \
- \
- template<typename GetSetT> typename std::enable_if<!std::is_class<GetSetT>::value, void>::type \
- set##name2(GetSetT name) { this->name = name; } /* small type: simple setter that just copies */ \
- \
- template<typename GetSetT> typename std::enable_if<std::is_class<GetSetT>::value, void>::type \
- set##name2(GetSetT&& name) { this->name = std::move(name); } /* large type: move the rvalue ref */ \
- \
- template<typename GetSetT> typename std::enable_if<std::is_class<GetSetT>::value, void>::type \
- set##name2(const GetSetT& name) { this->name = name; } /* large type: copy the parameter */
+ template<typename GetSetT> void set##name2(GetSetT&& name) { this->name = std::forward<GetSetT>(name); }
#else