summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2019-10-27 16:59:10 +0100
committerMurray Cumming <murrayc@murrayc.com>2019-11-02 21:19:44 +0100
commite29a66d62cba712830cdb47b9081d6380f009548 (patch)
treefe342f4bb7550b5c66232298393f811bae22078c
parentcc73cfeb34cecb1ed1c80b4b9dbeabb667fe48bc (diff)
downloadsigc++-test-overloaded-functions.tar.gz
test_mem_fun(): Re-enable tests of overloaded functionstest-overloaded-functions
But, as with test_ptr_fun(), we need to specify the types. The compiler doesn't seem to be able to figure it out based on the values passed.
-rw-r--r--tests/test_mem_fun.cc31
-rw-r--r--tests/test_ptr_fun.cc3
2 files changed, 10 insertions, 24 deletions
diff --git a/tests/test_mem_fun.cc b/tests/test_mem_fun.cc
index dc21937..ee344af 100644
--- a/tests/test_mem_fun.cc
+++ b/tests/test_mem_fun.cc
@@ -5,10 +5,6 @@
#include "testutilities.h"
#include <sigc++/sigc++.h>
-// TODO: put something like #ifndef FORTE (some older version, I think) or AIX xlC... #else ...
-// #endif around:
-#define ENABLE_TEST_OF_OVERLOADED_FUNCTIONS 0
-
namespace
{
@@ -33,12 +29,10 @@ struct test
void foo_overloaded(char i1) { result_stream << "test::foo_overloaded(char " << int(i1) << ')'; }
-#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
void foo_overloaded(short i1)
{
result_stream << "test::foo_overloaded(short " << (int)i1 << ')';
}
-#endif
double foo_overloaded(int i1, int i2)
{
@@ -97,24 +91,22 @@ test_const_volatile_with_const_object()
util->check_result(result_stream, "test::foo_const_volatile(double 6)");
}
-#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
void
test_overloaded()
{
test t;
- sigc::mem_fun<char> (&test::foo_overloaded)(t, 7);
+
+ // We need to specify the types when using overloaded functions.
+
+ sigc::mem_fun<void, test, char> (&test::foo_overloaded)(t, 7);
util->check_result(result_stream, "test::foo_overloaded(char 7)");
- sigc::mem_fun<short> (&test::foo_overloaded)(t, 7);
+ sigc::mem_fun<void, test, short> (&test::foo_overloaded)(t, 7);
util->check_result(result_stream, "test::foo_overloaded(short 7)");
- // sigc::mem_fun(&test::foo_overloaded)(t, 7);
- // util->check_result(result_stream, "test::foo_overloaded(short 7)");
-
- sigc::mem_fun (&test::foo_overloaded)(t, 7, 8);
+ sigc::mem_fun<double, test, int, int> (&test::foo_overloaded)(t, 7, 8);
util->check_result(result_stream, "test::foo_overloaded(int 7, int 8)");
}
-#endif
void
test_bound()
@@ -138,13 +130,8 @@ test_bound()
sigc::mem_fun(t, &test::foo_volatile)(9);
util->check_result(result_stream, "test::foo_volatile(float 9)");
-#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
- sigc::mem_fun(t, &test::foo_overloaded)(9, 10);
- util->check_result(result_stream, "test::foo_overloaded(int 9, int 10)");
-
- sigc::mem_fun(t, &test::foo_overloaded)(9, 10);
+ sigc::mem_fun<double, test, test, int, int>(t, &test::foo_overloaded)(9, 10);
util->check_result(result_stream, "test::foo_overloaded(int 9, int 10)");
-#endif
}
class TestAutoDisconnect : public sigc::trackable
@@ -188,9 +175,7 @@ main(int argc, char* argv[])
test_const_volatile();
test_const_volatile_with_const_object();
-#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
- test_overload();
-#endif
+ test_overloaded();
test_bound();
diff --git a/tests/test_ptr_fun.cc b/tests/test_ptr_fun.cc
index b105389..6c29437 100644
--- a/tests/test_ptr_fun.cc
+++ b/tests/test_ptr_fun.cc
@@ -34,7 +34,8 @@ bar(char i1)
// Note: This doesn't work with some older versions of g++,
// even when we specify the return type.
// Hopefully those g++ versions are old enough now.
-void bar(float i1)
+void
+bar(float i1)
{
result_stream << "bar(float " << i1 << ")";
}