mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 11:25:40 +03:00
Fix C++11 compilation error / Chris Dyer
This commit is contained in:
parent
14e02978fc
commit
ffd62e994e
@ -40,6 +40,12 @@ template <class KeyIter, class ValueIter> class JointIter {
|
|||||||
swap(first.value_, second.value_);
|
swap(first.value_, second.value_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeepSwap(JointIter &other) {
|
||||||
|
using std::swap;
|
||||||
|
swap(*key_, *other.key_);
|
||||||
|
swap(*value_, *other.value_);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class JointProxy<KeyIter, ValueIter>;
|
friend class JointProxy<KeyIter, ValueIter>;
|
||||||
KeyIter key_;
|
KeyIter key_;
|
||||||
@ -84,10 +90,7 @@ template <class KeyIter, class ValueIter> class JointProxy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
friend void swap(JointProxy<KeyIter, ValueIter> first, JointProxy<KeyIter, ValueIter> second) {
|
friend void swap(JointProxy<KeyIter, ValueIter> first, JointProxy<KeyIter, ValueIter> second) {
|
||||||
// Allow argument-dependent lookup.
|
first.Inner().DeepSwap(second.Inner());
|
||||||
using std::swap;
|
|
||||||
swap(*first.inner_.key_, *second.inner_.key_);
|
|
||||||
swap(*first.inner_.value_, *second.inner_.value_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -47,4 +47,16 @@ BOOST_AUTO_TEST_CASE(char_int) {
|
|||||||
BOOST_CHECK_EQUAL(327, values[3]);
|
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
|
}} // namespace anonymous util
|
||||||
|
Loading…
Reference in New Issue
Block a user