mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-22 13:15:39 +08:00
refs #247 Improved CSequence comparison, and suppressed stupid warnings.
This commit is contained in:
@@ -83,6 +83,11 @@ win32-g++: QMAKE_CXXFLAGS_DEBUG += -Og
|
|||||||
|
|
||||||
equals(WORD_SIZE,64): BLACK_CONFIG -= FSX FS9
|
equals(WORD_SIZE,64): BLACK_CONFIG -= FSX FS9
|
||||||
|
|
||||||
|
###########################
|
||||||
|
# Suppress stupid warnings
|
||||||
|
###########################
|
||||||
|
win32-msvc*:DEFINES *= _SCL_SECURE_NO_WARNINGS
|
||||||
|
|
||||||
################################
|
################################
|
||||||
# Defines for conditional compilation
|
# Defines for conditional compilation
|
||||||
################################
|
################################
|
||||||
|
|||||||
@@ -20,8 +20,6 @@
|
|||||||
#include "json.h"
|
#include "json.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#define _SCL_SECURE_NO_WARNINGS // suppress MSVC unchecked iterator warning for std::transform
|
|
||||||
|
|
||||||
namespace BlackMisc
|
namespace BlackMisc
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -519,17 +519,33 @@ namespace BlackMisc
|
|||||||
return sorted(BlackMisc::Predicates::MemberLess(key1, keys...));
|
return sorted(BlackMisc::Predicates::MemberLess(key1, keys...));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
//! Equals operator.
|
||||||
* \brief Test for equality.
|
friend bool operator ==(const CSequence &a, const CSequence &b)
|
||||||
* \todo Improve inefficient implementation.
|
{
|
||||||
*/
|
if (a.size() != b.size()) { return false; }
|
||||||
bool operator ==(const CSequence &other) const { return (empty() && other.empty()) ? true : (size() != other.size() ? false : *pimpl() == *other.pimpl()); }
|
return std::equal(a.begin(), a.end(), b.begin());
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
//! Not equals operator.
|
||||||
* \brief Test for inequality.
|
friend bool operator !=(const CSequence &a, const CSequence &b) { return !(a == b); }
|
||||||
* \todo Improve inefficient implementation.
|
|
||||||
*/
|
//! Less than operator.
|
||||||
bool operator !=(const CSequence &other) const { return !(*this == other); }
|
friend bool operator <(const CSequence &a, const CSequence &b)
|
||||||
|
{
|
||||||
|
auto mm = std::mismatch(a.begin(), a.begin() + std::max(a.size(), b.size()), b.begin());
|
||||||
|
if (mm.first == a.end()) { return mm.second != b.end(); }
|
||||||
|
if (mm.second == b.end()) { return false; }
|
||||||
|
return *mm.first < *mm.second;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Greater than operator.
|
||||||
|
friend bool operator >(const CSequence &a, const CSequence &b) { return b < a; }
|
||||||
|
|
||||||
|
//! Less or equal than operator.
|
||||||
|
friend bool operator <=(const CSequence &a, const CSequence &b) { return !(b < a); }
|
||||||
|
|
||||||
|
//! Greater or equal operator.
|
||||||
|
friend bool operator >=(const CSequence &a, const CSequence &b) { return !(a < b); }
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Return an opaque pointer to the implementation container.
|
* \brief Return an opaque pointer to the implementation container.
|
||||||
@@ -566,7 +582,6 @@ namespace BlackMisc
|
|||||||
virtual void pop_back() = 0;
|
virtual void pop_back() = 0;
|
||||||
virtual iterator erase(iterator pos) = 0;
|
virtual iterator erase(iterator pos) = 0;
|
||||||
virtual iterator erase(iterator it1, iterator it2) = 0;
|
virtual iterator erase(iterator it1, iterator it2) = 0;
|
||||||
virtual bool operator ==(const PimplBase &other) const = 0;
|
|
||||||
virtual void *impl() = 0;
|
virtual void *impl() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -598,7 +613,6 @@ namespace BlackMisc
|
|||||||
void pop_back() override { m_impl.pop_back(); }
|
void pop_back() override { m_impl.pop_back(); }
|
||||||
iterator erase(iterator pos) override { return iterator::fromImpl(m_impl.erase(*static_cast<const typename C::iterator *>(pos.getImpl()))); }
|
iterator erase(iterator pos) override { return iterator::fromImpl(m_impl.erase(*static_cast<const typename C::iterator *>(pos.getImpl()))); }
|
||||||
iterator erase(iterator it1, iterator it2) override { return iterator::fromImpl(m_impl.erase(*static_cast<const typename C::iterator *>(it1.getImpl()), *static_cast<const typename C::iterator *>(it2.getImpl()))); }
|
iterator erase(iterator it1, iterator it2) override { return iterator::fromImpl(m_impl.erase(*static_cast<const typename C::iterator *>(it1.getImpl()), *static_cast<const typename C::iterator *>(it2.getImpl()))); }
|
||||||
bool operator ==(const PimplBase &other) const override { Pimpl copy = C(); for (auto i = other.cbegin(); i != other.cend(); ++i) copy.push_back(*i); return m_impl == copy.m_impl; }
|
|
||||||
void *impl() override { return &m_impl; }
|
void *impl() override { return &m_impl; }
|
||||||
private:
|
private:
|
||||||
C m_impl;
|
C m_impl;
|
||||||
|
|||||||
Reference in New Issue
Block a user