diff options
author | Chris Dyer <cdyer@allegro.clab.cs.cmu.edu> | 2014-01-28 00:18:37 -0500 |
---|---|---|
committer | Chris Dyer <cdyer@allegro.clab.cs.cmu.edu> | 2014-01-28 00:18:37 -0500 |
commit | 7f69662660746eb8559bd3f041bdc4184f639fad (patch) | |
tree | 5336b9626c8ce12dbd366cc637fec0987742bd47 /klm/util/joint_sort.hh | |
parent | dba017629ff32bbd0af8770ddee88082bb626bee (diff) | |
parent | eecc4cbf5a6e28f910130cd4a58444e9d4701ea9 (diff) |
Merge branch 'master' of github.com:redpony/cdec
Diffstat (limited to 'klm/util/joint_sort.hh')
-rw-r--r-- | klm/util/joint_sort.hh | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/klm/util/joint_sort.hh b/klm/util/joint_sort.hh index 1b43ddcf..13a52b67 100644 --- a/klm/util/joint_sort.hh +++ b/klm/util/joint_sort.hh @@ -9,7 +9,6 @@ #include <algorithm> #include <functional> -#include <iostream> namespace util { @@ -35,9 +34,10 @@ template <class KeyIter, class ValueIter> class JointIter { return *this; } - void swap(const JointIter &other) { - std::swap(key_, other.key_); - std::swap(value_, other.value_); + friend void swap(JointIter &first, JointIter &second) { + using std::swap; + swap(first.key_, second.key_); + swap(first.value_, second.value_); } private: @@ -83,9 +83,11 @@ template <class KeyIter, class ValueIter> class JointProxy { return *(inner_.key_); } - void swap(JointProxy<KeyIter, ValueIter> &other) { - std::swap(*inner_.key_, *other.inner_.key_); - std::swap(*inner_.value_, *other.inner_.value_); + friend void swap(JointProxy<KeyIter, ValueIter> first, JointProxy<KeyIter, ValueIter> second) { + // Allow argument-dependent lookup. + using std::swap; + swap(*first.inner_.key_, *second.inner_.key_); + swap(*first.inner_.value_, *second.inner_.value_); } private: @@ -138,14 +140,4 @@ template <class KeyIter, class ValueIter> void JointSort(const KeyIter &key_begi } // namespace util -namespace std { -template <class KeyIter, class ValueIter> void swap(util::detail::JointIter<KeyIter, ValueIter> &left, util::detail::JointIter<KeyIter, ValueIter> &right) { - left.swap(right); -} - -template <class KeyIter, class ValueIter> void swap(util::detail::JointProxy<KeyIter, ValueIter> &left, util::detail::JointProxy<KeyIter, ValueIter> &right) { - left.swap(right); -} -} // namespace std - #endif // UTIL_JOINT_SORT__ |