Skip to content

Commit fd4f2ac

Browse files
committed
STL compatibility fixes
1 parent 71d5341 commit fd4f2ac

File tree

3 files changed

+58
-38
lines changed

3 files changed

+58
-38
lines changed

‎include/shared_allocator/cached_allocator.hpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,24 @@ namespace salloc {
140140
141141
Does nothing and returns reference to this allocator. */
142142
template <class U>
143-
ThisType& operator=(const U&)
143+
ThisType& operator = (const U&)
144144
{
145145
return *this;
146146
}
147147

148+
/** Operator == for STL compatibility. */
149+
inline bool operator == (const ThisType&) throw()
150+
{
151+
return true;
152+
}
153+
154+
/** Operator == for STL compatibility. */
155+
template <class U, class W>
156+
inline bool operator == (const cached_allocator<U, W>&) throw()
157+
{
158+
return false;
159+
}
160+
148161
~cached_allocator()
149162
{
150163
private_clear();
@@ -337,21 +350,6 @@ namespace salloc {
337350

338351
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
339352

340-
/** Operator == for STL compatibility. */
341-
template <class T, class U>
342-
inline bool operator == (const ::salloc::cached_allocator<T, U>&, const ::salloc::cached_allocator<T, U>&) throw()
343-
{
344-
return true;
345-
}
346-
347-
template <class T, class U, class W, class Q>
348-
inline bool operator == (const ::salloc::cached_allocator<T, U>&, const ::salloc::cached_allocator<W, Q>&) throw()
349-
{
350-
return false;
351-
}
352-
353-
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
354-
355353
namespace std {
356354

357355
template <class T, class TAlloc>

‎include/shared_allocator/shared_allocator.hpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ namespace salloc {
205205

206206
/** \brief Empty copy constructor.
207207
208+
Does nothing. */
209+
shared_allocator(const other&) throw()
210+
{
211+
}
212+
213+
/** \brief Empty copy constructor.
214+
208215
Does nothing. */
209216
template <class U>
210217
shared_allocator(const shared_allocator<U>&) throw()
@@ -220,6 +227,19 @@ namespace salloc {
220227
return *this;
221228
}
222229

230+
/** Operator == for STL compatibility. */
231+
inline bool operator == (const other&) throw()
232+
{
233+
return true;
234+
}
235+
236+
/** Operator == for STL compatibility. */
237+
template <class U>
238+
inline bool operator == (const shared_allocator<U>&) throw()
239+
{
240+
return true;
241+
}
242+
223243
/** \brief Returns number of elements in allocated memory.
224244
225245
\param _memory Pointer to allocated memory.
@@ -326,13 +346,6 @@ namespace salloc {
326346

327347
} // END namespace salloc.
328348

329-
/** Operator == for STL compatibility. */
330-
template <class T, class U>
331-
inline bool operator == (const ::salloc::shared_allocator<T>&, const ::salloc::shared_allocator<U>&) throw()
332-
{
333-
return true;
334-
}
335-
336349
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
337350
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
338351

‎include/shared_allocator/size_cached_allocator.hpp

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ namespace salloc {
6262
{
6363
protected:
6464

65+
typedef size_cached_allocator<T, TAlloc> ThisType;
66+
6567
template <class U>
6668
using TSameAlloc = typename TAlloc::template rebind<U>::other;
6769

@@ -119,9 +121,16 @@ namespace salloc {
119121

120122
/** \brief Empty copy constructor.
121123
124+
Does nothing. */
125+
size_cached_allocator(const ThisType&) throw()
126+
{
127+
}
128+
129+
/** \brief Empty copy constructor.
130+
122131
Does nothing. */
123132
template <class U>
124-
size_cached_allocator(const size_cached_allocator<U>&) throw()
133+
size_cached_allocator(const U&) throw()
125134
{
126135
}
127136

@@ -136,11 +145,24 @@ namespace salloc {
136145
137146
Does nothing and returns reference to this allocator. */
138147
template <class U>
139-
size_cached_allocator<T>& operator=(const size_cached_allocator<U>&)
148+
size_cached_allocator<T>& operator = (const size_cached_allocator<U>&)
140149
{
141150
return *this;
142151
}
143152

153+
/** Operator == for STL compatibility. */
154+
inline bool operator == (const ThisType&) throw()
155+
{
156+
return true;
157+
}
158+
159+
/** Operator == for STL compatibility. */
160+
template <class U, class W>
161+
inline bool operator == (const size_cached_allocator<U, W>&) throw()
162+
{
163+
return false;
164+
}
165+
144166
~size_cached_allocator()
145167
{
146168
for (auto pCache : m_memoryCache)
@@ -351,19 +373,6 @@ namespace salloc {
351373

352374
} // END namespace salloc.
353375

354-
/** Operator == for STL compatibility. */
355-
template <class T, class U>
356-
inline bool operator == (const ::salloc::size_cached_allocator<T, U>&, const ::salloc::size_cached_allocator<T, U>&) throw()
357-
{
358-
return true;
359-
}
360-
361-
template <class T, class U, class W, class Q>
362-
inline bool operator == (const ::salloc::size_cached_allocator<T, U>&, const ::salloc::size_cached_allocator<W, Q>&) throw()
363-
{
364-
return false;
365-
}
366-
367376
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
368377
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
369378

0 commit comments

Comments
 (0)