Skip to content

Commit 63045b9

Browse files
authored
Merge pull request #1 from libsigcplusplus/master
Updating from the source repo.
2 parents a246891 + 12ad173 commit 63045b9

File tree

16 files changed

+47
-117
lines changed

16 files changed

+47
-117
lines changed

NEWS

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
2.99.11: (unstable)
2+
3+
libsigc++-3.0 now requires C++17. Use of C++17:
4+
* Use std::apply to simplify implementation.
5+
* Use std::invoke to make implementation more generic.
6+
* Use constexpr if to simplify implementation.
7+
8+
Build:
9+
* Require mm-common 0.9.12
10+
111
2.99.10: (unstable)
212

313
* slot_base::set_parent(): Create a dummy slot_rep if necessary

configure.ac

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
## You should have received a copy of the GNU Lesser General Public License
1616
## along with this library. If not, see <http://www.gnu.org/licenses/>.
1717

18-
AC_INIT([libsigc++], [2.99.10],
18+
AC_INIT([libsigc++], [2.99.11],
1919
[http://bugzilla.gnome.org/enter_bug.cgi?product=libsigc%2B%2B],
2020
[libsigc++], [http://libsigc.sourceforge.net/])
2121
AC_PREREQ([2.59])
@@ -32,12 +32,12 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
3232
AM_MAINTAINER_MODE
3333
AC_ARG_VAR([ACLOCAL_FLAGS], [aclocal flags, e.g. -I <macro dir>])
3434

35-
MM_PREREQ([0.9.10])
35+
MM_PREREQ([0.9.12])
3636
MM_INIT_MODULE([sigc++-3.0])
3737
MM_CONFIG_DOCTOOL_DIR([docs/docs])
3838

3939
AC_PROG_CXX
40-
MM_AX_CXX_COMPILE_STDCXX([14],[noext],[mandatory])
40+
MM_AX_CXX_COMPILE_STDCXX([17],[noext],[mandatory])
4141

4242
AC_DISABLE_STATIC
4343
LT_INIT([win32-dll])

sigc++/adaptors/adaptor_trait.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <sigc++/functors/ptr_fun.h>
2626
#include <sigc++/functors/mem_fun.h>
2727
#include <sigc++/adaptors/adaptor_base.h>
28+
#include <functional>
2829

2930
/*
3031
* The idea here is simple. To prevent the need to
@@ -96,7 +97,7 @@ struct adaptor_functor : public adaptor_base
9697
template <typename... T_arg>
9798
decltype(auto) operator()(T_arg&&... arg) const
9899
{
99-
return functor_(std::forward<T_arg>(arg)...);
100+
return std::invoke(functor_, std::forward<T_arg>(arg)...);
100101
}
101102

102103
/// Constructs an invalid functor.

sigc++/adaptors/bind.h

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <sigc++/tuple-utils/tuple_start.h>
2727
#include <sigc++/tuple-utils/tuple_end.h>
2828
#include <sigc++/tuple-utils/tuple_transform_each.h>
29+
#include <functional>
2930

3031

3132
namespace sigc
@@ -150,9 +151,7 @@ struct bind_functor : public adapts<T_functor>
150151
const auto t_end = internal::tuple_end<t_args_size - I_location>(t_args);
151152
const auto t_with_bound = std::tuple_cat(t_start, t_bound, t_end);
152153

153-
constexpr const auto seq =
154-
std::make_index_sequence<std::tuple_size<decltype(t_with_bound)>::value>();
155-
return call_functor_operator_parentheses(t_with_bound, seq);
154+
return std::apply(this->functor_, t_with_bound);
156155
}
157156

158157
/** Constructs a bind_functor object that binds an argument to the passed functor.
@@ -167,12 +166,6 @@ struct bind_functor : public adapts<T_functor>
167166
private:
168167
/// The arguments bound to the functor.
169168
std::tuple<bound_argument<T_bound>...> bound_;
170-
171-
template <typename T, std::size_t... Is>
172-
decltype(auto) call_functor_operator_parentheses(T&& tuple, std::index_sequence<Is...>)
173-
{
174-
return (this->functor_)(std::get<Is>(std::forward<T>(tuple))...);
175-
}
176169
};
177170

178171
/** Adaptor that binds argument(s) to the wrapped functor.
@@ -199,8 +192,7 @@ struct bind_functor<-1, T_functor, T_type...> : public adapts<T_functor>
199192
const auto t_bound = internal::tuple_transform_each<internal::TransformEachInvoker>(bound_);
200193
const auto t_with_bound = std::tuple_cat(t_args, t_bound);
201194

202-
constexpr auto seq = std::make_index_sequence<std::tuple_size<decltype(t_with_bound)>::value>();
203-
return call_functor_operator_parentheses(t_with_bound, seq);
195+
return std::apply(this->functor_, t_with_bound);
204196
}
205197

206198
/** Constructs a bind_functor object that binds an argument to the passed functor.
@@ -214,13 +206,6 @@ struct bind_functor<-1, T_functor, T_type...> : public adapts<T_functor>
214206

215207
/// The argument bound to the functor.
216208
std::tuple<bound_argument<T_type>...> bound_;
217-
218-
private:
219-
template <typename T, std::size_t... Is>
220-
decltype(auto) call_functor_operator_parentheses(T&& tuple, std::index_sequence<Is...>)
221-
{
222-
return (this->functor_)(std::get<Is>(std::forward<T>(tuple))...);
223-
}
224209
};
225210

226211
#ifndef DOXYGEN_SHOULD_SKIP_THIS

sigc++/adaptors/bind_return.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct bind_return_functor : public adapts<T_functor>
4949
template <typename... T_arg>
5050
inline typename unwrap_reference<T_return>::type operator()(T_arg... a)
5151
{
52-
this->functor_.template operator()<type_trait_pass_t<T_arg>...>(a...);
52+
std::invoke(this->functor_, a...);
5353
return ret_value_.invoke();
5454
}
5555

@@ -71,7 +71,7 @@ template <typename T_return, typename T_functor>
7171
typename unwrap_reference<T_return>::type
7272
bind_return_functor<T_return, T_functor>::operator()()
7373
{
74-
this->functor_();
74+
std::invoke(this->functor_);
7575
return ret_value_.invoke();
7676
}
7777

sigc++/adaptors/compose.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#ifndef SIGC_ADAPTORS_COMPOSE_H
2020
#define SIGC_ADAPTORS_COMPOSE_H
2121
#include <sigc++/adaptors/adapts.h>
22+
#include <functional>
2223

2324
namespace sigc
2425
{
@@ -61,12 +62,10 @@ namespace sigc
6162
template <typename T_setter, typename T_getter>
6263
struct compose1_functor : public adapts<T_setter>
6364
{
64-
decltype(auto) operator()() { return this->functor_(get_()); }
65-
6665
template <typename... T_arg>
6766
decltype(auto) operator()(T_arg&&... a)
6867
{
69-
return this->functor_(get_(std::forward<T_arg>(a)...));
68+
return std::invoke(this->functor_, get_(std::forward<T_arg>(a)...));
7069
}
7170

7271
/** Constructs a compose1_functor object that combines the passed functors.
@@ -95,12 +94,10 @@ struct compose1_functor : public adapts<T_setter>
9594
template <typename T_setter, typename T_getter1, typename T_getter2>
9695
struct compose2_functor : public adapts<T_setter>
9796
{
98-
decltype(auto) operator()() { return this->functor_(get1_(), get2_()); }
99-
10097
template <typename... T_arg>
10198
decltype(auto) operator()(T_arg... a)
10299
{
103-
return this->functor_(get1_(a...), get2_(a...));
100+
return std::invoke(this->functor_, get1_(a...), get2_(a...));
104101
}
105102

106103
/** Constructs a compose2_functor object that combines the passed functors.

sigc++/adaptors/exception_catch.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ struct exception_catch_functor : public adapts<T_functor>
8080
{
8181
try
8282
{
83-
return this->functor_();
83+
return std::invoke(this->functor_);
8484
}
8585
catch (...)
8686
{
@@ -93,7 +93,7 @@ struct exception_catch_functor : public adapts<T_functor>
9393
{
9494
try
9595
{
96-
return this->functor_.template operator()<type_trait_pass_t<T_arg>...>(a...);
96+
return std::invoke(this->functor_, a...);
9797
}
9898
catch (...)
9999
{

sigc++/adaptors/hide.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -102,28 +102,13 @@ struct hide_functor : public adapts<T_functor>
102102
const auto t_end = internal::tuple_end<size - index_ignore - 1>(t);
103103
const auto t_used = std::tuple_cat(t_start, t_end);
104104

105-
constexpr auto size_used = size - 1;
106-
107-
// TODO: Remove these? They are just here as a sanity check.
108-
static_assert(std::tuple_size<decltype(t_used)>::value == size_used, "Unexpected t_used size.");
109-
110-
const auto seq = std::make_index_sequence<size_used>();
111-
return call_functor_operator_parentheses(t_used, seq);
105+
return std::apply(this->functor_, t_used);
112106
}
113107

114108
/** Constructs a hide_functor object that adds a dummy parameter to the passed functor.
115109
* @param func Functor to invoke from operator()().
116110
*/
117111
explicit hide_functor(const T_functor& func) : adapts<T_functor>(func) {}
118-
119-
private:
120-
// TODO_variadic: Replace this with std::experimental::apply() if that becomes standard
121-
// C++, or add our own implementation, to avoid code duplication.
122-
template <typename T_tuple, std::size_t... Is>
123-
decltype(auto) call_functor_operator_parentheses(T_tuple& tuple, std::index_sequence<Is...>)
124-
{
125-
return this->functor_.template operator()(std::get<Is>(tuple)...);
126-
}
127112
};
128113

129114
#ifndef DOXYGEN_SHOULD_SKIP_THIS

sigc++/adaptors/retype.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ struct retype_functor : public adapts<T_functor>
8282
template <typename... T_arg>
8383
decltype(auto) operator()(T_arg... a)
8484
{
85-
return this->functor_.template operator()<type_trait_take_t<T_type>...>(
86-
static_cast<T_type>(a)...);
85+
return std::invoke(this->functor_, static_cast<T_type>(a)...);
8786
}
8887

8988
/** Constructs a retype_functor object that performs C-style casts on the parameters passed on to

sigc++/adaptors/retype_return.h

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,10 @@ namespace sigc
3636
template <typename T_return, typename T_functor>
3737
struct retype_return_functor : public adapts<T_functor>
3838
{
39-
T_return operator()();
40-
4139
template <typename... T_arg>
4240
inline T_return operator()(T_arg&&... a)
4341
{
44-
return T_return(this->functor_.template operator() < T_arg... > (std::forward<T_arg>(a)...));
42+
return T_return(std::invoke(this->functor_, std::forward<T_arg>(a)...));
4543
}
4644

4745
retype_return_functor() = default;
@@ -56,13 +54,6 @@ struct retype_return_functor : public adapts<T_functor>
5654
}
5755
};
5856

59-
template <typename T_return, typename T_functor>
60-
T_return
61-
retype_return_functor<T_return, T_functor>::operator()()
62-
{
63-
return T_return(this->functor_());
64-
}
65-
6657
/** Adaptor that performs a C-style cast on the return value of a functor.
6758
* This template specialization is for a void return. It drops the return value of the functor it
6859
* invokes.
@@ -76,25 +67,16 @@ retype_return_functor<T_return, T_functor>::operator()()
7667
template <typename T_functor>
7768
struct retype_return_functor<void, T_functor> : public adapts<T_functor>
7869
{
79-
void operator()();
80-
8170
template <typename... T_arg>
8271
inline void operator()(T_arg... a)
8372
{
84-
this->functor_.template operator()<T_arg...>(a...);
73+
std::invoke(this->functor_, a...);
8574
}
8675

8776
retype_return_functor() = default;
8877
retype_return_functor(type_trait_take_t<T_functor> functor) : adapts<T_functor>(functor) {}
8978
};
9079

91-
template <typename T_functor>
92-
void
93-
retype_return_functor<void, T_functor>::operator()()
94-
{
95-
this->functor_();
96-
}
97-
9880
#ifndef DOXYGEN_SHOULD_SKIP_THIS
9981
// template specialization of visitor<>::do_visit_each<>(action, functor):
10082
/** Performs a functor on each of the targets of a functor.

sigc++/adaptors/track_obj.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,14 @@ class track_obj_functor : public adapts<T_functor>
8080
{
8181
}
8282

83-
/** Invokes the wrapped functor.
84-
* @return The return value of the functor invocation.
85-
*/
86-
decltype(auto) operator()() { return this->functor_(); }
87-
8883
/** Invokes the wrapped functor passing on the arguments.
8984
* @param arg Arguments to be passed on to the functor.
9085
* @return The return value of the functor invocation.
9186
*/
9287
template <typename... T_arg>
9388
decltype(auto) operator()(T_arg&&... arg)
9489
{
95-
return this->functor_.template operator()<type_trait_pass_t<T_arg>...>(
96-
std::forward<T_arg>(arg)...);
90+
return std::invoke(this->functor_, std::forward<T_arg>(arg)...);
9791
}
9892

9993
#ifndef DOXYGEN_SHOULD_SKIP_THIS

sigc++/functors/mem_fun.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <sigc++/type_traits.h>
2222
#include <sigc++/limit_reference.h>
2323
#include <sigc++/member_method_trait.h>
24+
#include <functional>
2425

2526
// implementation notes:
2627
// - we do not use bind here, because it would introduce
@@ -113,7 +114,7 @@ class mem_functor
113114
*/
114115
decltype(auto) operator()(obj_type_with_modifier& obj, type_trait_take_t<T_arg>... a) const
115116
{
116-
return (obj.*func_ptr_)(a...);
117+
return std::invoke(func_ptr_, obj, a...);
117118
}
118119

119120
protected:
@@ -152,7 +153,7 @@ class bound_mem_functor : mem_functor<T_func, T_arg...>
152153
*/
153154
decltype(auto) operator()(type_trait_take_t<T_arg>... a) const
154155
{
155-
return (obj_.invoke().*(this->func_ptr_))(a...);
156+
return std::invoke(this->func_ptr_, obj_.invoke(), a...);
156157
}
157158

158159
// protected:

sigc++/functors/ptr_fun.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#ifndef SIGC_FUNCTORS_PTR_FUN_H
2020
#define SIGC_FUNCTORS_PTR_FUN_H
2121
#include <sigc++/type_traits.h>
22+
#include <functional>
2223

2324
namespace sigc
2425
{
@@ -92,7 +93,9 @@ class pointer_functor<T_return(T_args...)>
9293
* @param a Arguments to be passed on to the function.
9394
* @return The return value of the function invocation.
9495
*/
95-
T_return operator()(type_trait_take_t<T_args>... a) const { return func_ptr_(a...); }
96+
T_return operator()(type_trait_take_t<T_args>... a) const {
97+
return std::invoke(func_ptr_, a...);
98+
}
9699
};
97100

98101
/** Creates a functor of type sigc::pointer_functor which wraps an existing non-member function.

sigc++/functors/slot.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <sigc++/visit_each.h>
2424
#include <sigc++/adaptors/adaptor_trait.h>
2525
#include <sigc++/functors/slot_base.h>
26+
#include <functional>
2627

2728
#include <memory>
2829

@@ -190,8 +191,10 @@ class slot<T_return(T_arg...)> : public slot_base
190191
*/
191192
inline T_return operator()(type_trait_take_t<T_arg>... a) const
192193
{
193-
if (!empty() && !blocked())
194-
return (reinterpret_cast<call_type>(slot_base::rep_->call_))(slot_base::rep_, a...);
194+
if (!empty() && !blocked()) {
195+
return std::invoke(reinterpret_cast<call_type>(slot_base::rep_->call_), slot_base::rep_, a...);
196+
}
197+
195198
return T_return();
196199
}
197200

sigc++/signal.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ struct signal_emit
246246
*/
247247
T_return operator()(const slot_type& slot) const
248248
{
249-
const auto seq = std::make_index_sequence<std::tuple_size<decltype(a_)>::value>();
250-
return call_call_type_operator_parentheses_with_tuple(slot, a_, seq);
249+
return std::apply(slot, a_);
251250
}
252251

253252
/** Executes a list of slots using an accumulator of type @e T_accumulator.
@@ -274,15 +273,6 @@ struct signal_emit
274273

275274
private:
276275
std::tuple<type_trait_take_t<T_arg>...> a_;
277-
278-
// TODO_variadic: Replace this with std::experimental::apply() if that becomes standard
279-
// C++, or add our own implementation, to avoid code duplication.
280-
template <std::size_t... Is>
281-
decltype(auto) call_call_type_operator_parentheses_with_tuple(
282-
const slot_type& slot, const std::tuple<T_arg...>& tuple, std::index_sequence<Is...>) const
283-
{
284-
return (slot)(std::get<Is>(tuple)...);
285-
}
286276
};
287277

288278
/** Abstracts signal emission.

0 commit comments

Comments
 (0)