Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2015-03-23 17:47:20 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:40:49 +0300
commiteccc58347b21362ede0d46a8c191bda2043980e9 (patch)
tree030cf4e705b2e257154924055902529138219192 /coding/dd_vector.hpp
parent774b0b050b4a0094e017ab31a2ba00e8a7a52ebe (diff)
[coding] Fixed unsigned -> signed value conversion.
Diffstat (limited to 'coding/dd_vector.hpp')
-rw-r--r--coding/dd_vector.hpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/coding/dd_vector.hpp b/coding/dd_vector.hpp
index 7b0e2df879..e5f56985dc 100644
--- a/coding/dd_vector.hpp
+++ b/coding/dd_vector.hpp
@@ -1,11 +1,8 @@
#pragma once
#include "reader.hpp"
-#include "varint.hpp"
#include "../base/assert.hpp"
-#include "../base/base.hpp"
#include "../base/exception.hpp"
-#include "../base/src_point.hpp"
#include "../std/type_traits.hpp"
#include "../std/iterator_facade.hpp"
@@ -14,14 +11,13 @@
template <
typename T,
class TReader,
- typename TSize = uint32_t,
- typename TDifference = ptrdiff_t
+ typename TSize = uint32_t
> class DDVector
{
public:
typedef T value_type;
typedef TSize size_type;
- typedef TDifference difference_type;
+ typedef typename make_signed<size_type>::type difference_type;
typedef TReader ReaderType;
DECLARE_EXCEPTION(OpenException, RootException);
@@ -63,6 +59,7 @@ public:
const_iterator(ReaderType const * pReader, size_type i, size_type size)
: m_pReader(pReader), m_I(i), m_bValueRead(false), m_Size(size)
{
+ ASSERT(static_cast<difference_type>(m_Size) >= 0, ());
}
#else
const_iterator(ReaderType const * pReader, size_type i)
@@ -96,7 +93,8 @@ public:
ASSERT_LESS_OR_EQUAL(it.m_I, it.m_Size, (it.m_bValueRead));
ASSERT_EQUAL(m_Size, it.m_Size, (m_I, it.m_I, m_bValueRead, it.m_bValueRead));
ASSERT(m_pReader == it.m_pReader, (m_I, m_Size, it.m_I, it.m_Size));
- return it.m_I - m_I;
+ return (static_cast<difference_type>(it.m_I) -
+ static_cast<difference_type>(m_I));
}
void increment()