Skip to content

Commit a05dd26

Browse files
committed
C++17: limit_trackable_target: Use constexpr if to simplify code.
1 parent b71b38c commit a05dd26

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

sigc++/visit_each.h

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ struct limit_trackable_target
4242
template <typename T_type>
4343
void operator()(T_type&& type) const
4444
{
45-
using T_self = limit_trackable_target<T_action>;
46-
4745
//Only call action_() if T_Type derives from trackable.
48-
with_type<T_type, T_self>::execute_(std::forward<T_type>(type), *this);
46+
if constexpr(is_base_of_or_same_v<sigc::trackable, T_type>) {
47+
action_(type);
48+
}
4949
}
5050

5151
explicit limit_trackable_target(const T_action& action) : action_(action) {}
@@ -56,27 +56,6 @@ struct limit_trackable_target
5656
limit_trackable_target& operator=(limit_trackable_target&& src) = delete;
5757

5858
T_action action_;
59-
60-
private:
61-
template <typename T_type, typename T_limit, bool I_derived = is_base_of_or_same_v<sigc::trackable, T_type>>
62-
struct with_type;
63-
64-
// Specialization for I_derived = false
65-
template <typename T_type, typename T_limit>
66-
struct with_type<T_type, T_limit, false>
67-
{
68-
static void execute_(const T_type&, const T_limit&) {}
69-
};
70-
71-
// Specialization for I_derived = true
72-
template <typename T_type, typename T_limit>
73-
struct with_type<T_type, T_limit, true>
74-
{
75-
static void execute_(const T_type& type, const T_limit& action)
76-
{
77-
action.action_(type);
78-
}
79-
};
8059
};
8160

8261
} /* namespace internal */

0 commit comments

Comments
 (0)