refs #800 Use int as size_type for compatibility with Qt containers.

This commit is contained in:
Mathew Sutcliffe
2016-11-10 00:58:23 +00:00
committed by Klaus Basan
parent cb266f0326
commit 95bfff36b0
2 changed files with 36 additions and 4 deletions

View File

@@ -24,6 +24,15 @@
#include <utility>
#include <initializer_list>
// conditions matched with pop pragmas at bottom of file
#if defined(QT_CC_CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
#elif defined(Q_CC_MSVC) && defined(Q_OS_WIN64) && defined(QT_CC_WARNINGS)
#pragma warning(push)
#pragma warning(disable:4244)
#endif
namespace BlackMisc
{
@@ -73,7 +82,7 @@ namespace BlackMisc
typedef typename Iterators::ConstForwardIterator<T> const_iterator;
typedef const_iterator iterator; // can't modify elements in-place
typedef ptrdiff_t difference_type;
typedef intptr_t size_type;
typedef int size_type;
//! @}
//! Default constructor.
@@ -336,7 +345,7 @@ namespace BlackMisc
iterator end() override { return iterator::fromImpl(m_impl.end()); }
const_iterator end() const override { return const_iterator::fromImpl(m_impl.cend()); }
const_iterator cend() const override { return const_iterator::fromImpl(m_impl.cend()); }
size_type size() const override { return m_impl.size(); }
size_type size() const override { return static_cast<size_type>(m_impl.size()); }
bool empty() const override { return m_impl.empty(); }
void clear() override { m_impl.clear(); }
iterator insert(const T &value) override { return iterator::fromImpl(insertHelper(m_impl.insert(value))); }
@@ -377,4 +386,11 @@ Q_DECLARE_METATYPE(BlackMisc::CCollection<qlonglong>)
Q_DECLARE_METATYPE(BlackMisc::CCollection<qulonglong>)
// CCollection<double> not instantiated due to it being a dumb idea because of rounding issues
// conditions matched with pop pragmas at bottom of file
#if defined(QT_CC_CLANG)
#pragma clang diagnostic pop
#elif defined(Q_CC_MSVC) && defined(Q_OS_WIN64) && defined(QT_CC_WARNINGS)
#pragma warning(pop)
#endif
#endif // guard

View File

@@ -23,6 +23,15 @@
#include <utility>
#include <initializer_list>
// conditions matched with pop pragmas at bottom of file
#if defined(QT_CC_CLANG)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
#elif defined(Q_CC_MSVC) && defined(Q_OS_WIN64) && defined(QT_CC_WARNINGS)
#pragma warning(push)
#pragma warning(disable:4244)
#endif
namespace BlackMisc
{
@@ -49,7 +58,7 @@ namespace BlackMisc
typedef typename Iterators::ConstRandomAccessIterator<T> const_iterator;
typedef typename Iterators::RandomAccessIterator<T> iterator;
typedef ptrdiff_t difference_type;
typedef intptr_t size_type;
typedef int size_type;
//! @}
//! Default constructor.
@@ -587,7 +596,7 @@ namespace BlackMisc
const_reference front() const override { return m_impl.front(); }
reference back() override { return m_impl.back(); }
const_reference back() const override { return m_impl.back(); }
size_type size() const override { return m_impl.size(); }
size_type size() const override { return static_cast<size_type>(m_impl.size()); }
bool empty() const override { return m_impl.empty(); }
void clear() override { m_impl.clear(); }
iterator insert(iterator pos, const T &value) override { return iterator::fromImpl(m_impl.insert(pos.template getImpl<const typename C::iterator>(), value)); }
@@ -619,4 +628,11 @@ Q_DECLARE_METATYPE(BlackMisc::CSequence<qlonglong>)
Q_DECLARE_METATYPE(BlackMisc::CSequence<qulonglong>)
Q_DECLARE_METATYPE(BlackMisc::CSequence<double>)
// conditions matched with pop pragmas at bottom of file
#if defined(QT_CC_CLANG)
#pragma clang diagnostic pop
#elif defined(Q_CC_MSVC) && defined(Q_OS_WIN64) && defined(QT_CC_WARNINGS)
#pragma warning(pop)
#endif
#endif //BLACKMISC_SEQUENCE_H