summaryrefslogtreecommitdiff
path: root/secblock.h
diff options
context:
space:
mode:
authorweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2005-07-12 04:23:32 +0000
committerweidai <weidai@57ff6487-cd31-0410-9ec3-f628ee90f5f0>2005-07-12 04:23:32 +0000
commitd5ebf62bed594d1fe6ab616a6bbcbcf0a5892d47 (patch)
tree4b03760892a97a9bc452ebe8b7793bbebd402ad4 /secblock.h
parentfa39f51809b4da54a5c2adb3e183b1a625cefb92 (diff)
downloadcryptopp-d5ebf62bed594d1fe6ab616a6bbcbcf0a5892d47.tar.gz
port to MSVC .NET 2005 beta 2
git-svn-id: svn://svn.code.sf.net/p/cryptopp/code/trunk/c5@198 57ff6487-cd31-0410-9ec3-f628ee90f5f0
Diffstat (limited to 'secblock.h')
-rw-r--r--secblock.h52
1 files changed, 24 insertions, 28 deletions
diff --git a/secblock.h b/secblock.h
index 2b254e4..a828ba2 100644
--- a/secblock.h
+++ b/secblock.h
@@ -203,11 +203,16 @@ template <class T, class A = AllocatorWithCleanup<T> >
class SecBlock
{
public:
- explicit SecBlock(unsigned int size=0)
+ typedef typename A::value_type value_type;
+ typedef typename A::pointer iterator;
+ typedef typename A::const_pointer const_iterator;
+ typedef typename A::size_type size_type;
+
+ explicit SecBlock(size_type size=0)
: m_size(size) {m_ptr = m_alloc.allocate(size, NULL);}
SecBlock(const SecBlock<T, A> &t)
: m_size(t.m_size) {m_ptr = m_alloc.allocate(m_size, NULL); memcpy(m_ptr, t.m_ptr, m_size*sizeof(T));}
- SecBlock(const T *t, unsigned int len)
+ SecBlock(const T *t, size_type len)
: m_size(len)
{
m_ptr = m_alloc.allocate(len, NULL);
@@ -238,26 +243,17 @@ public:
{return m_ptr;}
#endif
- template <typename I>
- T *operator +(I offset)
- {return m_ptr+offset;}
+// T *operator +(size_type offset)
+// {return m_ptr+offset;}
- template <typename I>
- const T *operator +(I offset) const
- {return m_ptr+offset;}
+// const T *operator +(size_type offset) const
+// {return m_ptr+offset;}
- template <typename I>
- T& operator[](I index)
- {assert(index >= 0 && (unsigned int)index < m_size); return m_ptr[index];}
+// T& operator[](size_type index)
+// {assert(index >= 0 && index < m_size); return m_ptr[index];}
- template <typename I>
- const T& operator[](I index) const
- {assert(index >= 0 && (unsigned int)index < m_size); return m_ptr[index];}
-
- typedef typename A::value_type value_type;
- typedef typename A::pointer iterator;
- typedef typename A::const_pointer const_iterator;
- typedef typename A::size_type size_type;
+// const T& operator[](size_type index) const
+// {assert(index >= 0 && index < m_size); return m_ptr[index];}
iterator begin()
{return m_ptr;}
@@ -274,7 +270,7 @@ public:
size_type size() const {return m_size;}
bool empty() const {return m_size == 0;}
- void Assign(const T *t, unsigned int len)
+ void Assign(const T *t, size_type len)
{
New(len);
memcpy(m_ptr, t, len*sizeof(T));
@@ -294,7 +290,7 @@ public:
SecBlock<T, A>& operator+=(const SecBlock<T, A> &t)
{
- unsigned int oldSize = m_size;
+ size_type oldSize = m_size;
Grow(m_size+t.m_size);
memcpy(m_ptr+oldSize, t.m_ptr, t.m_size*sizeof(T));
return *this;
@@ -318,19 +314,19 @@ public:
return !operator==(t);
}
- void New(unsigned int newSize)
+ void New(size_type newSize)
{
m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, false);
m_size = newSize;
}
- void CleanNew(unsigned int newSize)
+ void CleanNew(size_type newSize)
{
New(newSize);
memset(m_ptr, 0, m_size*sizeof(T));
}
- void Grow(unsigned int newSize)
+ void Grow(size_type newSize)
{
if (newSize > m_size)
{
@@ -339,7 +335,7 @@ public:
}
}
- void CleanGrow(unsigned int newSize)
+ void CleanGrow(size_type newSize)
{
if (newSize > m_size)
{
@@ -349,7 +345,7 @@ public:
}
}
- void resize(unsigned int newSize)
+ void resize(size_type newSize)
{
m_ptr = m_alloc.reallocate(m_ptr, m_size, newSize, true);
m_size = newSize;
@@ -364,7 +360,7 @@ public:
//private:
A m_alloc;
- unsigned int m_size;
+ size_type m_size;
T *m_ptr;
};
@@ -382,7 +378,7 @@ template <class T, unsigned int S, class A = FixedSizeAllocatorWithCleanup<T, S,
class SecBlockWithHint : public SecBlock<T, A>
{
public:
- explicit SecBlockWithHint(unsigned int size) : SecBlock<T, A>(size) {}
+ explicit SecBlockWithHint(size_t size) : SecBlock<T, A>(size) {}
};
template<class T, class U>