aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-12-16 18:55:18 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-12-16 18:55:18 +0000
commita71cdd3cdc1873659745b742ed1b1756c4aa2722 (patch)
tree1555f693609ef412ca197be17e6387cd2ab35d5a
parentf715cb80090cb3e21b3cd3fac697575863a15b2c (diff)
downloadpaludis-a71cdd3cdc1873659745b742ed1b1756c4aa2722.tar.gz
paludis-a71cdd3cdc1873659745b742ed1b1756c4aa2722.tar.xz
Let IndirectIterator work on iterators too
-rw-r--r--paludis/util/indirect_iterator.hh6
-rw-r--r--paludis/util/indirect_iterator_TEST.cc21
2 files changed, 27 insertions, 0 deletions
diff --git a/paludis/util/indirect_iterator.hh b/paludis/util/indirect_iterator.hh
index 5956b56..cf76d08 100644
--- a/paludis/util/indirect_iterator.hh
+++ b/paludis/util/indirect_iterator.hh
@@ -29,6 +29,12 @@
namespace paludis
{
template <typename T_>
+ struct IndirectIteratorValueType
+ {
+ typedef typename std::iterator_traits<T_>::value_type Type;
+ };
+
+ template <typename T_>
struct IndirectIteratorValueType<T_ *>
{
typedef T_ Type;
diff --git a/paludis/util/indirect_iterator_TEST.cc b/paludis/util/indirect_iterator_TEST.cc
index 98498a2..350cbdd 100644
--- a/paludis/util/indirect_iterator_TEST.cc
+++ b/paludis/util/indirect_iterator_TEST.cc
@@ -19,6 +19,8 @@
*/
#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/iterator_funcs.hh>
#include <test/test_runner.hh>
#include <test/test_framework.hh>
#include <vector>
@@ -136,5 +138,24 @@ namespace test_cases
std::for_each(v.begin(), v.end(), Deleter());
}
} test_indirect_iterator_list_p_int;
+
+ struct IndirectIteratorListListIterIntTest : TestCase
+ {
+ IndirectIteratorListListIterIntTest() : TestCase("list<list<int>::iterator>") { }
+
+ void run()
+ {
+ std::list<int> v;
+ v.push_back(5);
+ v.push_back(10);
+
+ std::list<std::list<int>::iterator> w;
+ w.push_back(v.begin());
+ w.push_back(next(v.begin()));
+
+ TEST_CHECK_EQUAL(join(indirect_iterator(w.begin()), indirect_iterator(w.end()), ", "), "5, 10");
+
+ }
+ } test_indirect_iterator_list_list_int_iter;
}