summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Heafield <github@kheafield.com>2014-01-27 22:18:14 -0800
committerKenneth Heafield <github@kheafield.com>2014-01-27 22:18:14 -0800
commit827eae2d1d2f62c00db21e1d43aabf904dd8ff8d (patch)
tree124746d243edda6ffb4a5dbf8cda54329751b439
parentc2be67fa0c5f294da5ac40ca7d5db41a36a56c64 (diff)
Another attempted fix at the sorting iterator for C++11
-rw-r--r--klm/util/joint_sort.hh2
-rw-r--r--klm/util/joint_sort_test.cc12
2 files changed, 13 insertions, 1 deletions
diff --git a/klm/util/joint_sort.hh b/klm/util/joint_sort.hh
index 5589c558..b1ec48e2 100644
--- a/klm/util/joint_sort.hh
+++ b/klm/util/joint_sort.hh
@@ -90,7 +90,7 @@ template <class KeyIter, class ValueIter> class JointProxy {
}
friend void swap(JointProxy<KeyIter, ValueIter> first, JointProxy<KeyIter, ValueIter> second) {
- first.DeepSwap(second);
+ first.Inner().DeepSwap(second.Inner());
}
private:
diff --git a/klm/util/joint_sort_test.cc b/klm/util/joint_sort_test.cc
index 4dc85916..b24c602c 100644
--- a/klm/util/joint_sort_test.cc
+++ b/klm/util/joint_sort_test.cc
@@ -47,4 +47,16 @@ BOOST_AUTO_TEST_CASE(char_int) {
BOOST_CHECK_EQUAL(327, values[3]);
}
+BOOST_AUTO_TEST_CASE(swap_proxy) {
+ char keys[2] = {0, 1};
+ int values[2] = {2, 3};
+ detail::JointProxy<char *, int *> first(keys, values);
+ detail::JointProxy<char *, int *> second(keys + 1, values + 1);
+ swap(first, second);
+ BOOST_CHECK_EQUAL(1, keys[0]);
+ BOOST_CHECK_EQUAL(0, keys[1]);
+ BOOST_CHECK_EQUAL(3, values[0]);
+ BOOST_CHECK_EQUAL(2, values[1]);
+}
+
}} // namespace anonymous util