[libsigc++2/variadic] exception_catch_functor::operator():



commit f6f4204a0831efad73c1dbb4f58fd82058fc9d04
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Jan 15 10:31:09 2016 +0100

    exception_catch_functor::operator():
    
    Remove the unnecessary operator()() overload.
    This did need me to change the test code so that it doesn't try to
    provide a catch function that returns something, but that seems
    more correct anyway.

 sigc++/adaptors/exception_catch.h |   13 -------------
 tests/test_exception_catch.cc     |   19 ++++++++++++++++++-
 2 files changed, 18 insertions(+), 14 deletions(-)
---
diff --git a/sigc++/adaptors/exception_catch.h b/sigc++/adaptors/exception_catch.h
index 992ffd7..1ea7c3b 100644
--- a/sigc++/adaptors/exception_catch.h
+++ b/sigc++/adaptors/exception_catch.h
@@ -99,10 +99,6 @@ struct exception_catch_functor<T_functor, T_catcher, void> : public adapts<T_fun
   typedef void result_type;
   typedef typename adapts<T_functor>::adaptor_type adaptor_type;
 
-  void
-  operator()();
-
-
   template <class... T_arg>
   decltype(auto)
   operator()(T_arg... _A_a)
@@ -127,15 +123,6 @@ struct exception_catch_functor<T_functor, T_catcher, void> : public adapts<T_fun
     T_catcher catcher_;
 };
 
-template <class T_functor, class T_catcher>
-void exception_catch_functor<T_functor, T_catcher, void>::operator()()
-  {
-    try
-      { this->functor_(); } // I don't understand why void return doesn't work here (Martin)
-    catch (...)
-      { this->catcher_(); }
-  }
-
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 //template specialization of visitor<>::do_visit_each<>(action, functor):
 template <class T_functor, class T_catcher, class T_return>
diff --git a/tests/test_exception_catch.cc b/tests/test_exception_catch.cc
index f8f6e02..6ae7e51 100644
--- a/tests/test_exception_catch.cc
+++ b/tests/test_exception_catch.cc
@@ -63,6 +63,23 @@ struct my_catch
   }
 };
 
+struct my_catch_void
+{
+  void operator()()
+  {
+    try
+    {
+      throw;
+    }
+    catch (std::range_error e) // catch what types we know
+    {
+      result_stream << "caught " << e.what();
+    }
+
+    // all else continues out.
+  }
+};
+
 } // end anonymous namespace
 
 int main(int argc, char* argv[])
@@ -78,7 +95,7 @@ int main(int argc, char* argv[])
   result_stream << sigc::exception_catch(g(), my_catch())();
   util->check_result(result_stream, "g() caught out of range 1");
 
-  sigc::exception_catch(g_void(), my_catch())(); // void test
+  sigc::exception_catch(g_void(), my_catch_void())(); // void test
   util->check_result(result_stream, "g_void() caught out of range ");
 
   return util->get_result_and_delete_instance() ? EXIT_SUCCESS : EXIT_FAILURE;


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