diff options
author | Michael Elkstrand <michael@elehack.net> | 2007-07-28 12:19:01 +0000 |
---|---|---|
committer | Murray Cumming <murrayc@src.gnome.org> | 2007-07-28 12:19:01 +0000 |
commit | 5f22a6a28079867680033f8dd9b6433e93f74d56 (patch) | |
tree | 3653cb895ade9157bf1653726fc18cb55e3a7f1f /tests/test_accum_iter.cc | |
parent | 552bd485674ebffcdd0bf9a9970d98b02e0ceeb6 (diff) | |
download | sigc++-5f22a6a28079867680033f8dd9b6433e93f74d56.tar.gz |
slot_iterator_buf, slot_reverse_iterator_buf: Added typedefs for
2007-07-28 Michael Elkstrand <michael@elehack.net>
* sigc++/macros/signal.h.m4: slot_iterator_buf,
slot_reverse_iterator_buf: Added typedefs for
value_type, reference, and pointer, so that these
iterators are more like standard C++ iterators, so they can
be used with standard C++ algorithms.
* tests/Makefile.am:
* tests/test_accum_iter.cc: Added a test for this.
Bug #417926.
svn path=/trunk/; revision=284
Diffstat (limited to 'tests/test_accum_iter.cc')
-rw-r--r-- | tests/test_accum_iter.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test_accum_iter.cc b/tests/test_accum_iter.cc new file mode 100644 index 0000000..462c2ec --- /dev/null +++ b/tests/test_accum_iter.cc @@ -0,0 +1,43 @@ +#include <sigc++/sigc++.h> +#include <iostream> +#include <algorithm> +#include <functional> + +#include <new> +SIGC_USING_STD(new) + +static int ident(int i) +{ + return i; +} + +template<typename T> +struct min_accum +{ + typedef T result_type; + + template<class I> + typename std::iterator_traits<I>::value_type operator()(I i1, I i2) + { + return *std::min_element(i1, i2); + } +}; + +int main() +{ + sigc::signal0<int,min_accum<int> > signal; + + signal.connect( + sigc::bind(sigc::ptr_fun(ident), 3)); + signal.connect( + sigc::bind(sigc::ptr_fun(ident), 1)); + signal.connect( + sigc::bind(sigc::ptr_fun(ident), 42)); + + int rv = signal(); + std::cout <<rv <<std::endl; + if (rv != 1) + return 1; + else + return 0; +} |