Commit b94c2a12 authored by Milo Yip's avatar Milo Yip

Adding swap() for GenericMember

parent 0739a3e8
......@@ -17,10 +17,7 @@ static void printIt(const Value &doc) {
}
struct NameComparator {
bool operator()(
const GenericMember<UTF8<>, MemoryPoolAllocator<> > &lhs,
const GenericMember<UTF8<>, MemoryPoolAllocator<> > &rhs) const
{
bool operator()(const Value::Member &lhs, const Value::Member &rhs) const {
return (strcmp(lhs.name.GetString(), rhs.name.GetString()) < 0);
}
};
......
......@@ -66,6 +66,12 @@ template <typename Encoding, typename Allocator>
struct GenericMember {
GenericValue<Encoding, Allocator> name; //!< name of member (must be a string)
GenericValue<Encoding, Allocator> value; //!< value of member.
// swap() for std::sort() and other potential use in STL.
friend inline void swap(GenericMember& a, GenericMember& b) RAPIDJSON_NOEXCEPT {
a.name.Swap(b.name);
a.value.Swap(b.value);
}
};
///////////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment