[libsigcplusplus] visit_each.h: Add and use is_base_of_or_same_v to avoid duplication.



commit 01b702b2e04be6a055c1ef39ed2bdbbefa5c1eea
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Apr 1 09:53:30 2016 +0200

    visit_each.h: Add and use is_base_of_or_same_v to avoid duplication.

 sigc++/visit_each.h |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/sigc++/visit_each.h b/sigc++/visit_each.h
index 3e3fdc0..5daaf85 100644
--- a/sigc++/visit_each.h
+++ b/sigc++/visit_each.h
@@ -28,6 +28,10 @@ namespace sigc
 namespace internal
 {
 
+template <class Base, class Derived>
+constexpr bool is_base_of_or_same_v =
+  std::is_base_of<Base, Derived>::value || std::is_same<Base, Derived>::value;
+
 // This should really be an inner class of limit_derived_target, without the T_limit template type,
 // But the SUN CC 5.7 (not earlier versions) compiler finds it ambiguous when we specify a
 // particular specialization of it.
@@ -61,7 +65,7 @@ struct limit_derived_target
   template <class T_type>
   void operator()(const T_type& _A_type) const
   {
-    with_type<std::is_base_of<T_target, T_type>::value || std::is_same<T_target, T_type>::value,
+    with_type<is_base_of_or_same_v<T_target, T_type>,
       T_type, T_self>::execute_(_A_type, *this);
   }
 
@@ -101,8 +105,7 @@ struct limit_derived_target<T_target*, T_action>
   template <class T_type>
   void operator()(const T_type& _A_type) const
   {
-    with_type_pointer<std::is_base_of<T_target, T_type>::value ||
-                        std::is_same<T_target, T_type>::value,
+    with_type_pointer<is_base_of_or_same_v<T_target, T_type>,
       T_type, T_self>::execute_(_A_type, *this);
   }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]