[libsigcplusplus/c++17v4: 1/3] C++17: limit_trackable_target: Use constexpr if to simplify code.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsigcplusplus/c++17v4: 1/3] C++17: limit_trackable_target: Use constexpr if to simplify code.
- Date: Wed, 21 Sep 2016 07:19:52 +0000 (UTC)
commit a05dd26eac473cac931dd444aaa6300335c870ca
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Jul 7 22:36:07 2016 +0200
C++17: limit_trackable_target: Use constexpr if to simplify code.
sigc++/visit_each.h | 27 +++------------------------
1 files changed, 3 insertions(+), 24 deletions(-)
---
diff --git a/sigc++/visit_each.h b/sigc++/visit_each.h
index e28d385..51b53aa 100644
--- a/sigc++/visit_each.h
+++ b/sigc++/visit_each.h
@@ -42,10 +42,10 @@ struct limit_trackable_target
template <typename T_type>
void operator()(T_type&& type) const
{
- using T_self = limit_trackable_target<T_action>;
-
//Only call action_() if T_Type derives from trackable.
- with_type<T_type, T_self>::execute_(std::forward<T_type>(type), *this);
+ if constexpr(is_base_of_or_same_v<sigc::trackable, T_type>) {
+ action_(type);
+ }
}
explicit limit_trackable_target(const T_action& action) : action_(action) {}
@@ -56,27 +56,6 @@ struct limit_trackable_target
limit_trackable_target& operator=(limit_trackable_target&& src) = delete;
T_action action_;
-
-private:
- template <typename T_type, typename T_limit, bool I_derived = is_base_of_or_same_v<sigc::trackable,
T_type>>
- struct with_type;
-
- // Specialization for I_derived = false
- template <typename T_type, typename T_limit>
- struct with_type<T_type, T_limit, false>
- {
- static void execute_(const T_type&, const T_limit&) {}
- };
-
- // Specialization for I_derived = true
- template <typename T_type, typename T_limit>
- struct with_type<T_type, T_limit, true>
- {
- static void execute_(const T_type& type, const T_limit& action)
- {
- action.action_(type);
- }
- };
};
} /* namespace internal */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]