From 617276cf47db463159263c359f7db09fcb6aaa9e Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Wed, 28 Mar 2018 20:53:59 +0200 Subject: [PATCH 001/265] configure.ac: Require C++17. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 44f9174b..64c651dd 100644 --- a/configure.ac +++ b/configure.ac @@ -37,7 +37,7 @@ MM_INIT_MODULE([sigc++-3.0]) MM_CONFIG_DOCTOOL_DIR([docs/docs]) AC_PROG_CXX -MM_AX_CXX_COMPILE_STDCXX([14],[noext],[mandatory]) +MM_AX_CXX_COMPILE_STDCXX([17],[noext],[mandatory]) AC_DISABLE_STATIC LT_INIT([win32-dll]) From 025934b5585e003a36cabf7f1f9e17796ec7c290 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Thu, 7 Jul 2016 22:36:07 +0200 Subject: [PATCH 002/265] C++17: limit_trackable_target: Use constexpr if to simplify code. --- sigc++/visit_each.h | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/sigc++/visit_each.h b/sigc++/visit_each.h index 50a58eb8..dc622317 100644 --- a/sigc++/visit_each.h +++ b/sigc++/visit_each.h @@ -43,10 +43,10 @@ struct limit_trackable_target template void operator()(T_type&& type) const { - using T_self = limit_trackable_target; - //Only call action_() if T_Type derives from trackable. - with_type::execute_(std::forward(type), *this); + if constexpr(is_base_of_or_same_v) { + action_(type); + } } explicit limit_trackable_target(const T_action& action) : action_(action) {} @@ -57,27 +57,6 @@ struct limit_trackable_target limit_trackable_target& operator=(limit_trackable_target&& src) = delete; T_action action_; - -private: - template > - struct with_type; - - // Specialization for I_derived = false - template - struct with_type - { - static void execute_(const T_type&, const T_limit&) {} - }; - - // Specialization for I_derived = true - template - struct with_type - { - static void execute_(const T_type& type, const T_limit& action) - { - action.action_(type); - } - }; }; } /* namespace internal */ From 7c88951dc959896feed019e19c7a457296c10c0c Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sat, 7 Apr 2018 22:05:05 +0200 Subject: [PATCH 003/265] C++17: Replace some call_*() helpers with std::apply(). --- sigc++/adaptors/bind.h | 20 ++------------------ sigc++/adaptors/hide.h | 17 +---------------- sigc++/signal.h | 12 +----------- 3 files changed, 4 insertions(+), 45 deletions(-) diff --git a/sigc++/adaptors/bind.h b/sigc++/adaptors/bind.h index 08e1ee77..91731ef4 100644 --- a/sigc++/adaptors/bind.h +++ b/sigc++/adaptors/bind.h @@ -150,9 +150,7 @@ struct bind_functor : public adapts const auto t_end = internal::tuple_end(t_args); const auto t_with_bound = std::tuple_cat(t_start, t_bound, t_end); - constexpr const auto seq = - std::make_index_sequence::value>(); - return call_functor_operator_parentheses(t_with_bound, seq); + return std::apply(this->functor_, t_with_bound); } /** Constructs a bind_functor object that binds an argument to the passed functor. @@ -167,12 +165,6 @@ struct bind_functor : public adapts private: /// The arguments bound to the functor. std::tuple...> bound_; - - template - decltype(auto) call_functor_operator_parentheses(T&& tuple, std::index_sequence) - { - return (this->functor_)(std::get(std::forward(tuple))...); - } }; /** Adaptor that binds argument(s) to the wrapped functor. @@ -199,8 +191,7 @@ struct bind_functor<-1, T_functor, T_type...> : public adapts const auto t_bound = internal::tuple_transform_each(bound_); const auto t_with_bound = std::tuple_cat(t_args, t_bound); - constexpr auto seq = std::make_index_sequence::value>(); - return call_functor_operator_parentheses(t_with_bound, seq); + return std::apply(this->functor_, t_with_bound); } /** Constructs a bind_functor object that binds an argument to the passed functor. @@ -214,13 +205,6 @@ struct bind_functor<-1, T_functor, T_type...> : public adapts /// The argument bound to the functor. std::tuple...> bound_; - -private: - template - decltype(auto) call_functor_operator_parentheses(T&& tuple, std::index_sequence) - { - return (this->functor_)(std::get(std::forward(tuple))...); - } }; #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/sigc++/adaptors/hide.h b/sigc++/adaptors/hide.h index 6b17cea6..8d9d1455 100644 --- a/sigc++/adaptors/hide.h +++ b/sigc++/adaptors/hide.h @@ -102,28 +102,13 @@ struct hide_functor : public adapts const auto t_end = internal::tuple_end(t); const auto t_used = std::tuple_cat(t_start, t_end); - constexpr auto size_used = size - 1; - - // TODO: Remove these? They are just here as a sanity check. - static_assert(std::tuple_size::value == size_used, "Unexpected t_used size."); - - const auto seq = std::make_index_sequence(); - return call_functor_operator_parentheses(t_used, seq); + return std::apply(this->functor_, t_used); } /** Constructs a hide_functor object that adds a dummy parameter to the passed functor. * @param func Functor to invoke from operator()(). */ explicit hide_functor(const T_functor& func) : adapts(func) {} - -private: - // TODO_variadic: Replace this with std::experimental::apply() if that becomes standard - // C++, or add our own implementation, to avoid code duplication. - template - decltype(auto) call_functor_operator_parentheses(T_tuple& tuple, std::index_sequence) - { - return this->functor_.template operator()(std::get(tuple)...); - } }; #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/sigc++/signal.h b/sigc++/signal.h index 3403e571..311e7987 100644 --- a/sigc++/signal.h +++ b/sigc++/signal.h @@ -246,8 +246,7 @@ struct signal_emit */ T_return operator()(const slot_type& slot) const { - const auto seq = std::make_index_sequence::value>(); - return call_call_type_operator_parentheses_with_tuple(slot, a_, seq); + return std::apply(slot, a_); } /** Executes a list of slots using an accumulator of type @e T_accumulator. @@ -274,15 +273,6 @@ struct signal_emit private: std::tuple...> a_; - - // TODO_variadic: Replace this with std::experimental::apply() if that becomes standard - // C++, or add our own implementation, to avoid code duplication. - template - decltype(auto) call_call_type_operator_parentheses_with_tuple( - const slot_type& slot, const std::tuple& tuple, std::index_sequence) const - { - return (slot)(std::get(tuple)...); - } }; /** Abstracts signal emission. From 5a4164b47535f8c134e52c9effeb2a1e0dea8e44 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sat, 7 Apr 2018 22:27:31 +0200 Subject: [PATCH 004/265] Build: Require mm-common 0.9.12 This version allows the check for C++17 support. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 64c651dd..3077198e 100644 --- a/configure.ac +++ b/configure.ac @@ -32,7 +32,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AM_MAINTAINER_MODE AC_ARG_VAR([ACLOCAL_FLAGS], [aclocal flags, e.g. -I ]) -MM_PREREQ([0.9.10]) +MM_PREREQ([0.9.12]) MM_INIT_MODULE([sigc++-3.0]) MM_CONFIG_DOCTOOL_DIR([docs/docs]) From f3da00bcbc68145092c4977604b997fcd53bcd09 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sat, 7 Apr 2018 22:31:43 +0200 Subject: [PATCH 005/265] C++17: Use std::invoke(). This makes code more generic. Maybe this will let us simplify code. --- sigc++/adaptors/adaptor_trait.h | 3 ++- sigc++/adaptors/bind.h | 1 + sigc++/adaptors/bind_return.h | 3 ++- sigc++/adaptors/compose.h | 13 +++++++++---- sigc++/adaptors/exception_catch.h | 3 ++- sigc++/adaptors/retype.h | 1 + sigc++/adaptors/retype_return.h | 6 ++++-- sigc++/adaptors/track_obj.h | 5 ++++- sigc++/functors/mem_fun.h | 5 +++-- sigc++/functors/ptr_fun.h | 5 ++++- sigc++/functors/slot.h | 7 +++++-- sigc++/visit_each.h | 3 ++- 12 files changed, 39 insertions(+), 16 deletions(-) diff --git a/sigc++/adaptors/adaptor_trait.h b/sigc++/adaptors/adaptor_trait.h index 7a534e80..fe7f3e79 100644 --- a/sigc++/adaptors/adaptor_trait.h +++ b/sigc++/adaptors/adaptor_trait.h @@ -25,6 +25,7 @@ #include #include #include +#include /* * The idea here is simple. To prevent the need to @@ -96,7 +97,7 @@ struct adaptor_functor : public adaptor_base template decltype(auto) operator()(T_arg&&... arg) const { - return functor_(std::forward(arg)...); + return std::invoke(functor_, std::forward(arg)...); } /// Constructs an invalid functor. diff --git a/sigc++/adaptors/bind.h b/sigc++/adaptors/bind.h index 91731ef4..bd19b321 100644 --- a/sigc++/adaptors/bind.h +++ b/sigc++/adaptors/bind.h @@ -26,6 +26,7 @@ #include #include #include +#include namespace sigc diff --git a/sigc++/adaptors/bind_return.h b/sigc++/adaptors/bind_return.h index 0da105e9..99a4eb61 100644 --- a/sigc++/adaptors/bind_return.h +++ b/sigc++/adaptors/bind_return.h @@ -49,6 +49,7 @@ struct bind_return_functor : public adapts template inline typename unwrap_reference::type operator()(T_arg... a) { + //TODO: Use std::invoke() here? this->functor_.template operator()...>(a...); return ret_value_.invoke(); } @@ -71,7 +72,7 @@ template typename unwrap_reference::type bind_return_functor::operator()() { - this->functor_(); + std::invoke(this->functor_); return ret_value_.invoke(); } diff --git a/sigc++/adaptors/compose.h b/sigc++/adaptors/compose.h index fb4e0816..f8b21d11 100644 --- a/sigc++/adaptors/compose.h +++ b/sigc++/adaptors/compose.h @@ -19,6 +19,7 @@ #ifndef SIGC_ADAPTORS_COMPOSE_H #define SIGC_ADAPTORS_COMPOSE_H #include +#include namespace sigc { @@ -61,12 +62,14 @@ namespace sigc template struct compose1_functor : public adapts { - decltype(auto) operator()() { return this->functor_(get_()); } + decltype(auto) operator()() { + return std::invoke(this->functor_, get_()); + } template decltype(auto) operator()(T_arg&&... a) { - return this->functor_(get_(std::forward(a)...)); + return std::invoke(this->functor_, get_(std::forward(a)...)); } /** Constructs a compose1_functor object that combines the passed functors. @@ -95,12 +98,14 @@ struct compose1_functor : public adapts template struct compose2_functor : public adapts { - decltype(auto) operator()() { return this->functor_(get1_(), get2_()); } + decltype(auto) operator()() { + return std::invoke(this->functor_, get1_(), get2_()); + } template decltype(auto) operator()(T_arg... a) { - return this->functor_(get1_(a...), get2_(a...)); + return std::invoke(this->functor_, get1_(a...), get2_(a...)); } /** Constructs a compose2_functor object that combines the passed functors. diff --git a/sigc++/adaptors/exception_catch.h b/sigc++/adaptors/exception_catch.h index a4c6c2ce..7f7e5691 100644 --- a/sigc++/adaptors/exception_catch.h +++ b/sigc++/adaptors/exception_catch.h @@ -80,7 +80,7 @@ struct exception_catch_functor : public adapts { try { - return this->functor_(); + return std::invoke(this->functor_); } catch (...) { @@ -93,6 +93,7 @@ struct exception_catch_functor : public adapts { try { + //TODO: Use std::invoke here? return this->functor_.template operator()...>(a...); } catch (...) diff --git a/sigc++/adaptors/retype.h b/sigc++/adaptors/retype.h index 32f778bd..b006e4cd 100644 --- a/sigc++/adaptors/retype.h +++ b/sigc++/adaptors/retype.h @@ -82,6 +82,7 @@ struct retype_functor : public adapts template decltype(auto) operator()(T_arg... a) { + //TODO: Use std::invoke() here? return this->functor_.template operator()...>( static_cast(a)...); } diff --git a/sigc++/adaptors/retype_return.h b/sigc++/adaptors/retype_return.h index 9e5df6f9..2b5d776e 100644 --- a/sigc++/adaptors/retype_return.h +++ b/sigc++/adaptors/retype_return.h @@ -41,6 +41,7 @@ struct retype_return_functor : public adapts template inline T_return operator()(T_arg&&... a) { + //TODO: Use std::invoke() here? return T_return(this->functor_.template operator() < T_arg... > (std::forward(a)...)); } @@ -60,7 +61,7 @@ template T_return retype_return_functor::operator()() { - return T_return(this->functor_()); + return T_return(std::invoke(this->functor_)); } /** Adaptor that performs a C-style cast on the return value of a functor. @@ -81,6 +82,7 @@ struct retype_return_functor : public adapts template inline void operator()(T_arg... a) { + //TODO: Use std::invoke() here? this->functor_.template operator()(a...); } @@ -92,7 +94,7 @@ template void retype_return_functor::operator()() { - this->functor_(); + std::invoke(this->functor_); } #ifndef DOXYGEN_SHOULD_SKIP_THIS diff --git a/sigc++/adaptors/track_obj.h b/sigc++/adaptors/track_obj.h index 4419ffbf..6e02bc4a 100644 --- a/sigc++/adaptors/track_obj.h +++ b/sigc++/adaptors/track_obj.h @@ -83,7 +83,9 @@ class track_obj_functor : public adapts /** Invokes the wrapped functor. * @return The return value of the functor invocation. */ - decltype(auto) operator()() { return this->functor_(); } + decltype(auto) operator()() { + return std::invoke(this->functor_); + } /** Invokes the wrapped functor passing on the arguments. * @param arg Arguments to be passed on to the functor. @@ -92,6 +94,7 @@ class track_obj_functor : public adapts template decltype(auto) operator()(T_arg&&... arg) { + //TODO: Use std::invoke() here? return this->functor_.template operator()...>( std::forward(arg)...); } diff --git a/sigc++/functors/mem_fun.h b/sigc++/functors/mem_fun.h index d53b967a..b4a1b68b 100644 --- a/sigc++/functors/mem_fun.h +++ b/sigc++/functors/mem_fun.h @@ -21,6 +21,7 @@ #include #include #include +#include // implementation notes: // - we do not use bind here, because it would introduce @@ -113,7 +114,7 @@ class mem_functor */ decltype(auto) operator()(obj_type_with_modifier& obj, type_trait_take_t... a) const { - return (obj.*func_ptr_)(a...); + return std::invoke(func_ptr_, obj, a...); } protected: @@ -152,7 +153,7 @@ class bound_mem_functor : mem_functor */ decltype(auto) operator()(type_trait_take_t... a) const { - return (obj_.invoke().*(this->func_ptr_))(a...); + return std::invoke(this->func_ptr_, obj_.invoke(), a...); } // protected: diff --git a/sigc++/functors/ptr_fun.h b/sigc++/functors/ptr_fun.h index 12e20155..c680a2e3 100644 --- a/sigc++/functors/ptr_fun.h +++ b/sigc++/functors/ptr_fun.h @@ -19,6 +19,7 @@ #ifndef SIGC_FUNCTORS_PTR_FUN_H #define SIGC_FUNCTORS_PTR_FUN_H #include +#include namespace sigc { @@ -92,7 +93,9 @@ class pointer_functor * @param a Arguments to be passed on to the function. * @return The return value of the function invocation. */ - T_return operator()(type_trait_take_t... a) const { return func_ptr_(a...); } + T_return operator()(type_trait_take_t... a) const { + return std::invoke(func_ptr_, a...); + } }; /** Creates a functor of type sigc::pointer_functor which wraps an existing non-member function. diff --git a/sigc++/functors/slot.h b/sigc++/functors/slot.h index 7326fcdf..fb6c2d23 100644 --- a/sigc++/functors/slot.h +++ b/sigc++/functors/slot.h @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -190,8 +191,10 @@ class slot : public slot_base */ inline T_return operator()(type_trait_take_t... a) const { - if (!empty() && !blocked()) - return (reinterpret_cast(slot_base::rep_->call_))(slot_base::rep_, a...); + if (!empty() && !blocked()) { + return std::invoke(reinterpret_cast(slot_base::rep_->call_), slot_base::rep_, a...); + } + return T_return(); } diff --git a/sigc++/visit_each.h b/sigc++/visit_each.h index dc622317..46a05049 100644 --- a/sigc++/visit_each.h +++ b/sigc++/visit_each.h @@ -21,6 +21,7 @@ #include #include #include // std::forward +#include namespace sigc { @@ -45,7 +46,7 @@ struct limit_trackable_target { //Only call action_() if T_Type derives from trackable. if constexpr(is_base_of_or_same_v) { - action_(type); + std::invoke(action_, type); } } From 107d09760f152279d87a072a40462983334f3e09 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sun, 8 Apr 2018 20:37:32 +0200 Subject: [PATCH 006/265] C++17: More use of std::invoke(). The use of template operator() here was maybe to deal with awkward compilers, but now we can just expect them to support std::invoke() from C++17. --- sigc++/adaptors/bind_return.h | 3 +-- sigc++/adaptors/exception_catch.h | 3 +-- sigc++/adaptors/retype.h | 4 +--- sigc++/adaptors/retype_return.h | 6 ++---- sigc++/adaptors/track_obj.h | 4 +--- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/sigc++/adaptors/bind_return.h b/sigc++/adaptors/bind_return.h index 99a4eb61..cb5a26a6 100644 --- a/sigc++/adaptors/bind_return.h +++ b/sigc++/adaptors/bind_return.h @@ -49,8 +49,7 @@ struct bind_return_functor : public adapts template inline typename unwrap_reference::type operator()(T_arg... a) { - //TODO: Use std::invoke() here? - this->functor_.template operator()...>(a...); + std::invoke(this->functor_, a...); return ret_value_.invoke(); } diff --git a/sigc++/adaptors/exception_catch.h b/sigc++/adaptors/exception_catch.h index 7f7e5691..ed60d0c5 100644 --- a/sigc++/adaptors/exception_catch.h +++ b/sigc++/adaptors/exception_catch.h @@ -93,8 +93,7 @@ struct exception_catch_functor : public adapts { try { - //TODO: Use std::invoke here? - return this->functor_.template operator()...>(a...); + return std::invoke(this->functor_, a...); } catch (...) { diff --git a/sigc++/adaptors/retype.h b/sigc++/adaptors/retype.h index b006e4cd..a628f95f 100644 --- a/sigc++/adaptors/retype.h +++ b/sigc++/adaptors/retype.h @@ -82,9 +82,7 @@ struct retype_functor : public adapts template decltype(auto) operator()(T_arg... a) { - //TODO: Use std::invoke() here? - return this->functor_.template operator()...>( - static_cast(a)...); + return std::invoke(this->functor_, static_cast(a)...); } /** Constructs a retype_functor object that performs C-style casts on the parameters passed on to diff --git a/sigc++/adaptors/retype_return.h b/sigc++/adaptors/retype_return.h index 2b5d776e..350e223c 100644 --- a/sigc++/adaptors/retype_return.h +++ b/sigc++/adaptors/retype_return.h @@ -41,8 +41,7 @@ struct retype_return_functor : public adapts template inline T_return operator()(T_arg&&... a) { - //TODO: Use std::invoke() here? - return T_return(this->functor_.template operator() < T_arg... > (std::forward(a)...)); + return T_return(std::invoke(this->functor_, std::forward(a)...)); } retype_return_functor() = default; @@ -82,8 +81,7 @@ struct retype_return_functor : public adapts template inline void operator()(T_arg... a) { - //TODO: Use std::invoke() here? - this->functor_.template operator()(a...); + std::invoke(this->functor_, a...); } retype_return_functor() = default; diff --git a/sigc++/adaptors/track_obj.h b/sigc++/adaptors/track_obj.h index 6e02bc4a..b4dc266c 100644 --- a/sigc++/adaptors/track_obj.h +++ b/sigc++/adaptors/track_obj.h @@ -94,9 +94,7 @@ class track_obj_functor : public adapts template decltype(auto) operator()(T_arg&&... arg) { - //TODO: Use std::invoke() here? - return this->functor_.template operator()...>( - std::forward(arg)...); + return std::invoke(this->functor_, std::forward(arg)...); } #ifndef DOXYGEN_SHOULD_SKIP_THIS From 12c3addc77ae88def1d5d6de97b69d3b8a4a4269 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Tue, 10 Apr 2018 21:12:00 +0200 Subject: [PATCH 007/265] compose: Remove unnecessary overloads. --- sigc++/adaptors/compose.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/sigc++/adaptors/compose.h b/sigc++/adaptors/compose.h index f8b21d11..5a3616f1 100644 --- a/sigc++/adaptors/compose.h +++ b/sigc++/adaptors/compose.h @@ -62,10 +62,6 @@ namespace sigc template struct compose1_functor : public adapts { - decltype(auto) operator()() { - return std::invoke(this->functor_, get_()); - } - template decltype(auto) operator()(T_arg&&... a) { @@ -98,10 +94,6 @@ struct compose1_functor : public adapts template struct compose2_functor : public adapts { - decltype(auto) operator()() { - return std::invoke(this->functor_, get1_(), get2_()); - } - template decltype(auto) operator()(T_arg... a) { From 12dd49b00f67eee9438035ae17db52b42ccdb3f1 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Tue, 10 Apr 2018 21:15:22 +0200 Subject: [PATCH 008/265] retype_return: Remove unnecessary overloads. --- sigc++/adaptors/retype_return.h | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/sigc++/adaptors/retype_return.h b/sigc++/adaptors/retype_return.h index 350e223c..57959f90 100644 --- a/sigc++/adaptors/retype_return.h +++ b/sigc++/adaptors/retype_return.h @@ -36,8 +36,6 @@ namespace sigc template struct retype_return_functor : public adapts { - T_return operator()(); - template inline T_return operator()(T_arg&&... a) { @@ -56,13 +54,6 @@ struct retype_return_functor : public adapts } }; -template -T_return -retype_return_functor::operator()() -{ - return T_return(std::invoke(this->functor_)); -} - /** Adaptor that performs a C-style cast on the return value of a functor. * This template specialization is for a void return. It drops the return value of the functor it * invokes. @@ -76,8 +67,6 @@ retype_return_functor::operator()() template struct retype_return_functor : public adapts { - void operator()(); - template inline void operator()(T_arg... a) { @@ -88,13 +77,6 @@ struct retype_return_functor : public adapts retype_return_functor(type_trait_take_t functor) : adapts(functor) {} }; -template -void -retype_return_functor::operator()() -{ - std::invoke(this->functor_); -} - #ifndef DOXYGEN_SHOULD_SKIP_THIS // template specialization of visitor<>::do_visit_each<>(action, functor): /** Performs a functor on each of the targets of a functor. From 2ff7cbf1007fb387d3ad68a3a0ed4c32c193f680 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Tue, 10 Apr 2018 21:18:10 +0200 Subject: [PATCH 009/265] track_obj: Remove unnecessary overload. --- sigc++/adaptors/track_obj.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/sigc++/adaptors/track_obj.h b/sigc++/adaptors/track_obj.h index b4dc266c..c7e75e59 100644 --- a/sigc++/adaptors/track_obj.h +++ b/sigc++/adaptors/track_obj.h @@ -80,13 +80,6 @@ class track_obj_functor : public adapts { } - /** Invokes the wrapped functor. - * @return The return value of the functor invocation. - */ - decltype(auto) operator()() { - return std::invoke(this->functor_); - } - /** Invokes the wrapped functor passing on the arguments. * @param arg Arguments to be passed on to the functor. * @return The return value of the functor invocation. From 12ad173361ce3f8fe2a3cee8c53397891e33abd1 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sun, 8 Apr 2018 21:58:33 +0200 Subject: [PATCH 010/265] 2.99.11 --- NEWS | 10 ++++++++++ configure.ac | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 8c44af8d..1d0b92ae 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,13 @@ +2.99.11: (unstable) + +libsigc++-3.0 now requires C++17. Use of C++17: +* Use std::apply to simplify implementation. +* Use std::invoke to make implementation more generic. +* Use constexpr if to simplify implementation. + +Build: +* Require mm-common 0.9.12 + 2.99.10: (unstable) * slot_base::set_parent(): Create a dummy slot_rep if necessary diff --git a/configure.ac b/configure.ac index 3077198e..1af431d7 100644 --- a/configure.ac +++ b/configure.ac @@ -15,7 +15,7 @@ ## You should have received a copy of the GNU Lesser General Public License ## along with this library. If not, see . -AC_INIT([libsigc++], [2.99.10], +AC_INIT([libsigc++], [2.99.11], [http://bugzilla.gnome.org/enter_bug.cgi?product=libsigc%2B%2B], [libsigc++], [http://libsigc.sourceforge.net/]) AC_PREREQ([2.59]) From 1759faf552248373714acc573b55421e86cb94cc Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sun, 15 Apr 2018 11:10:45 +0200 Subject: [PATCH 011/265] C++17: Update from murrayc-tuple-utils. From https://github.com/murraycu/murrayc-tuple-utils/commits/master This also uses the C++17 nested namespace syntax. Apart from tuple_transform_each, which seems to have a memory access problem, with both g++ and clang++, in its C++17 version. --- sigc++/tuple-utils/tuple_cdr.h | 26 +++++------- sigc++/tuple-utils/tuple_end.h | 69 +++++++++++++++----------------- sigc++/tuple-utils/tuple_start.h | 43 ++++++++------------ 3 files changed, 60 insertions(+), 78 deletions(-) diff --git a/sigc++/tuple-utils/tuple_cdr.h b/sigc++/tuple-utils/tuple_cdr.h index e0c17f7a..8577fef9 100644 --- a/sigc++/tuple-utils/tuple_cdr.h +++ b/sigc++/tuple-utils/tuple_cdr.h @@ -22,11 +22,7 @@ #include #include -namespace sigc -{ - -namespace internal -{ +namespace sigc::internal { /** * Get the type of a tuple without the first item. @@ -41,11 +37,11 @@ struct tuple_type_cdr> using type = std::tuple; }; -namespace detail -{ +namespace detail { template -constexpr decltype(auto) +constexpr +decltype(auto) tuple_cdr_impl(T&& t, std::index_sequence<0, I...>) { using cdr = typename tuple_type_cdr>::type; @@ -59,10 +55,10 @@ tuple_cdr_impl(T&& t, std::index_sequence<0, I...>) * This is analogous to std::tuple_cat(). */ template -constexpr decltype(auto) -tuple_cdr(T&& t) -{ - // We use std::decay_t<> because tuple_size is not defined for references. +constexpr +decltype(auto) +tuple_cdr(T&& t) { + //We use std::decay_t<> because tuple_size is not defined for references. constexpr auto size = std::tuple_size>::value; static_assert(size != 0, "tuple size must be non-zero"); @@ -70,8 +66,6 @@ tuple_cdr(T&& t) return detail::tuple_cdr_impl(std::forward(t), seq{}); } -} // namespace internal - -} // namespace sigc +} // namespace sigc::internal -#endif // SIGC_TUPLE_UTILS_TUPLE_CDR_H +#endif //SIGC_TUPLE_UTILS_TUPLE_CDR_H diff --git a/sigc++/tuple-utils/tuple_end.h b/sigc++/tuple-utils/tuple_end.h index 6eeac124..2f3572e6 100644 --- a/sigc++/tuple-utils/tuple_end.h +++ b/sigc++/tuple-utils/tuple_end.h @@ -20,58 +20,55 @@ #include -namespace sigc -{ +namespace sigc::internal { -namespace internal -{ - -namespace detail -{ +namespace detail { template -struct tuple_end_impl -{ - constexpr static decltype(auto) // typename tuple_type_end::type - tuple_end(T&& t) - { - static_assert(remove_from_start > 0, "remove_from_start must be more than zero."); - - using cdr = typename tuple_type_cdr>::type; - return tuple_end_impl::tuple_end(tuple_cdr(std::forward(t))); - } -}; - -template -struct tuple_end_impl -{ - constexpr static decltype(auto) tuple_end(T&& t) { return tuple_cdr(std::forward(t)); } +struct tuple_type_end_impl { + using type = typename tuple_type_end_impl>::type, + remove_from_start - 1>::type; }; template -struct tuple_end_impl -{ - constexpr static decltype(auto) tuple_end(T&& t) { return std::forward(t); } +struct tuple_type_end_impl { + using type = T; }; } // detail namespace +/** + * Get the type of a tuple with the last @a len types of the original. + */ +template +struct tuple_type_end + : detail::tuple_type_end_impl::value - len> {}; + /** * Get the tuple with the last @a len items of the original. */ template -constexpr decltype(auto) // typename tuple_type_end::type - tuple_end(T&& t) -{ - // We use std::decay_t<> because tuple_size is not defined for references. +constexpr +decltype(auto) // typename tuple_type_end::type +tuple_end(T&& t) { + //We use std::decay_t<> because tuple_size is not defined for references. constexpr auto size = std::tuple_size>::value; static_assert(len <= size, "The tuple size must be less than or equal to the length."); - constexpr auto size_start = size - len; - return detail::tuple_end_impl::tuple_end(std::forward(t)); -} -} // namespace internal + if constexpr(len == 0) { + // Recursive calls to tuple_cdr() would result in this eventually, + // but this avoids the extra work: + return std::tuple<>(); + } else if constexpr(size - len == 0) { + return std::forward(t); + } else if constexpr(size - len == 1) { + return tuple_cdr(std::forward(t)); + } else { + return tuple_end( + tuple_cdr(std::forward(t))); + } +} -} // namespace sigc +} // namespace sigc::internal; -#endif // SIGC_TUPLE_UTILS_TUPLE_END_H +#endif //SIGC_TUPLE_UTILS_TUPLE_END_H diff --git a/sigc++/tuple-utils/tuple_start.h b/sigc++/tuple-utils/tuple_start.h index 06491ce8..c220a928 100644 --- a/sigc++/tuple-utils/tuple_start.h +++ b/sigc++/tuple-utils/tuple_start.h @@ -21,21 +21,15 @@ #include #include -namespace sigc -{ +namespace sigc::internal { -namespace internal -{ - -namespace detail -{ +namespace detail { template struct tuple_type_start_impl; template -struct tuple_type_start_impl> -{ +struct tuple_type_start_impl> { using type = std::tuple::type...>; }; @@ -45,21 +39,20 @@ struct tuple_type_start_impl> * Get the type of a tuple with just the first @len items. */ template -struct tuple_type_start : detail::tuple_type_start_impl> -{ -}; +struct tuple_type_start + : detail::tuple_type_start_impl> {}; -namespace detail -{ +namespace detail { template struct tuple_start_impl; template -struct tuple_start_impl> -{ - static constexpr decltype(auto) tuple_start(T&& t) - { +struct tuple_start_impl> { + static + constexpr + decltype(auto) + tuple_start(T&& t) { constexpr auto size = std::tuple_size>::value; constexpr auto len = sizeof...(I); static_assert(len <= size, "The tuple size must be less than or equal to the length."); @@ -75,10 +68,10 @@ struct tuple_start_impl> * Get the tuple with the last @a len items of the original. */ template -constexpr decltype(auto) // typename tuple_type_end::type - tuple_start(T&& t) -{ - // We use std::decay_t<> because tuple_size is not defined for references. +constexpr +decltype(auto) // typename tuple_type_end::type +tuple_start(T&& t) { + //We use std::decay_t<> because tuple_size is not defined for references. constexpr auto size = std::tuple_size>::value; static_assert(len <= size, "The tuple size must be less than or equal to the length."); @@ -86,8 +79,6 @@ constexpr decltype(auto) // typename tuple_type_end::type std::forward(t)); } -} // namespace internal - -} // namespace sigc +} // namespace sigc::internal; -#endif // SIGC_TUPLE_UTILS_TUPLE_START_H +#endif //SIGC_TUPLE_UTILS_TUPLE_START_H From 5a95388651619b2a1399c2920d1fd1c09d513576 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sun, 15 Apr 2018 23:06:27 +0200 Subject: [PATCH 012/265] C++17: Update tuple_transform_each(). Update from murrayc-tuple-utils: https://github.com/murraycu/murrayc-tuple-utils/commits/master --- sigc++/tuple-utils/tuple_transform_each.h | 131 ++++++++-------------- 1 file changed, 49 insertions(+), 82 deletions(-) diff --git a/sigc++/tuple-utils/tuple_transform_each.h b/sigc++/tuple-utils/tuple_transform_each.h index ff7b6a42..7649e7f5 100644 --- a/sigc++/tuple-utils/tuple_transform_each.h +++ b/sigc++/tuple-utils/tuple_transform_each.h @@ -18,88 +18,57 @@ #ifndef SIGC_TUPLE_UTILS_TUPLE_TRANSFORM_EACH_H #define SIGC_TUPLE_UTILS_TUPLE_TRANSFORM_EACH_H +// #include #include #include #include #include -namespace sigc -{ +namespace sigc::internal { -namespace internal -{ - -namespace detail -{ +namespace detail { template