Skip to content

Commit e29a66d

Browse files
committed
test_mem_fun(): Re-enable tests of 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.
1 parent cc73cfe commit e29a66d

File tree

2 files changed

+10
-24
lines changed

2 files changed

+10
-24
lines changed

tests/test_mem_fun.cc

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
#include "testutilities.h"
66
#include <sigc++/sigc++.h>
77

8-
// TODO: put something like #ifndef FORTE (some older version, I think) or AIX xlC... #else ...
9-
// #endif around:
10-
#define ENABLE_TEST_OF_OVERLOADED_FUNCTIONS 0
11-
128
namespace
139
{
1410

@@ -33,12 +29,10 @@ struct test
3329

3430
void foo_overloaded(char i1) { result_stream << "test::foo_overloaded(char " << int(i1) << ')'; }
3531

36-
#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
3732
void foo_overloaded(short i1)
3833
{
3934
result_stream << "test::foo_overloaded(short " << (int)i1 << ')';
4035
}
41-
#endif
4236

4337
double foo_overloaded(int i1, int i2)
4438
{
@@ -97,24 +91,22 @@ test_const_volatile_with_const_object()
9791
util->check_result(result_stream, "test::foo_const_volatile(double 6)");
9892
}
9993

100-
#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
10194
void
10295
test_overloaded()
10396
{
10497
test t;
105-
sigc::mem_fun<char> (&test::foo_overloaded)(t, 7);
98+
99+
// We need to specify the types when using overloaded functions.
100+
101+
sigc::mem_fun<void, test, char> (&test::foo_overloaded)(t, 7);
106102
util->check_result(result_stream, "test::foo_overloaded(char 7)");
107103

108-
sigc::mem_fun<short> (&test::foo_overloaded)(t, 7);
104+
sigc::mem_fun<void, test, short> (&test::foo_overloaded)(t, 7);
109105
util->check_result(result_stream, "test::foo_overloaded(short 7)");
110106

111-
// sigc::mem_fun(&test::foo_overloaded)(t, 7);
112-
// util->check_result(result_stream, "test::foo_overloaded(short 7)");
113-
114-
sigc::mem_fun (&test::foo_overloaded)(t, 7, 8);
107+
sigc::mem_fun<double, test, int, int> (&test::foo_overloaded)(t, 7, 8);
115108
util->check_result(result_stream, "test::foo_overloaded(int 7, int 8)");
116109
}
117-
#endif
118110

119111
void
120112
test_bound()
@@ -138,13 +130,8 @@ test_bound()
138130
sigc::mem_fun(t, &test::foo_volatile)(9);
139131
util->check_result(result_stream, "test::foo_volatile(float 9)");
140132

141-
#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
142-
sigc::mem_fun(t, &test::foo_overloaded)(9, 10);
143-
util->check_result(result_stream, "test::foo_overloaded(int 9, int 10)");
144-
145-
sigc::mem_fun(t, &test::foo_overloaded)(9, 10);
133+
sigc::mem_fun<double, test, test, int, int>(t, &test::foo_overloaded)(9, 10);
146134
util->check_result(result_stream, "test::foo_overloaded(int 9, int 10)");
147-
#endif
148135
}
149136

150137
class TestAutoDisconnect : public sigc::trackable
@@ -188,9 +175,7 @@ main(int argc, char* argv[])
188175
test_const_volatile();
189176
test_const_volatile_with_const_object();
190177

191-
#if ENABLE_TEST_OF_OVERLOADED_FUNCTIONS
192-
test_overload();
193-
#endif
178+
test_overloaded();
194179

195180
test_bound();
196181

tests/test_ptr_fun.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ bar(char i1)
3434
// Note: This doesn't work with some older versions of g++,
3535
// even when we specify the return type.
3636
// Hopefully those g++ versions are old enough now.
37-
void bar(float i1)
37+
void
38+
bar(float i1)
3839
{
3940
result_stream << "bar(float " << i1 << ")";
4041
}

0 commit comments

Comments
 (0)