Skip to content

Commit 8c13616

Browse files
committed
3.05.02 release
1 parent 34706c3 commit 8c13616

23 files changed

+624
-124
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright (c) Electronic Arts Inc. All rights reserved.
3+
///////////////////////////////////////////////////////////////////////////////
4+
5+
#ifndef EASTL_FIXED_RING_BUFFER_H
6+
#define EASTL_FIXED_RING_BUFFER_H
7+
8+
#include <EASTL/internal/config.h>
9+
#include <EASTL/fixed_vector.h>
10+
#include <EASTL/bonus/ring_buffer.h>
11+
12+
EA_ONCE()
13+
14+
namespace eastl
15+
{
16+
17+
/// fixed_ring_buffer
18+
///
19+
/// This is a convenience template alias for creating a fixed-sized
20+
/// ring_buffer using eastl::fixed_vector as its storage container. This has
21+
/// been tricky for users to get correct due to the constructor requirements
22+
/// of eastl::ring_buffer leaking the implementation detail of the sentinel
23+
/// value being used internally. In addition, it was not obvious what the
24+
/// correct allocator_type template parameter should be used for containers
25+
/// providing both a default allocator type and an overflow allocator type.
26+
///
27+
/// We are over-allocating the fixed_vector container to accommodate the
28+
/// ring_buffer sentinel to prevent that implementation detail leaking into
29+
/// user code.
30+
///
31+
/// Example usage:
32+
///
33+
/// fixed_ring_buffer<int, 8> rb = {0, 1, 2, 3, 4, 5, 6, 7};
34+
/// or
35+
/// fixed_ring_buffer<int, 8> rb(8); // capacity doesn't need to respect sentinel
36+
/// rb.push_back(0);
37+
///
38+
///
39+
#if !defined(EA_COMPILER_NO_TEMPLATE_ALIASES)
40+
template <typename T, size_t N>
41+
using fixed_ring_buffer =
42+
ring_buffer<T, fixed_vector<T, N + 1, false>, typename fixed_vector<T, N + 1, false>::overflow_allocator_type>;
43+
#endif
44+
45+
} // namespace eastl
46+
47+
#endif // Header include guard
48+

include/EASTL/bonus/ring_buffer.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@
3232

3333
namespace eastl
3434
{
35+
/// EASTL_RING_BUFFER_DEFAULT_NAME
36+
///
37+
/// Defines a default container name in the absence of a user-provided name.
38+
///
39+
#ifndef EASTL_RING_BUFFER_DEFAULT_NAME
40+
#define EASTL_RING_BUFFER_DEFAULT_NAME EASTL_DEFAULT_NAME_PREFIX " ring_buffer" // Unless the user overrides something, this is "EASTL ring_buffer".
41+
#endif
42+
43+
/// EASTL_RING_BUFFER_DEFAULT_ALLOCATOR
44+
///
45+
#ifndef EASTL_RING_BUFFER_DEFAULT_ALLOCATOR
46+
#define EASTL_RING_BUFFER_DEFAULT_ALLOCATOR allocator_type(EASTL_RING_BUFFER_DEFAULT_NAME)
47+
#endif
48+
3549

3650
/// ring_buffer_iterator
3751
///
@@ -222,17 +236,17 @@ namespace eastl
222236
explicit ring_buffer(const allocator_type& allocator);
223237
ring_buffer(const this_type& x);
224238
#if EASTL_MOVE_SEMANTICS_ENABLED
225-
ring_buffer(this_type&& x);
226-
ring_buffer(this_type&& x, const allocator_type& allocator);
239+
ring_buffer(this_type&& x);
240+
ring_buffer(this_type&& x, const allocator_type& allocator);
227241
#endif
228-
ring_buffer(std::initializer_list<value_type> ilist, const allocator_type& allocator = allocator_type()); // This function sets the capacity to be equal to the size of the initializer list.
242+
ring_buffer(std::initializer_list<value_type> ilist, const allocator_type& allocator = EASTL_RING_BUFFER_DEFAULT_ALLOCATOR); // This function sets the capacity to be equal to the size of the initializer list.
229243

230244
// No destructor necessary. Default will do.
231245

232246
this_type& operator=(const this_type& x);
233247
this_type& operator=(std::initializer_list<value_type> ilist);
234248
#if EASTL_MOVE_SEMANTICS_ENABLED
235-
this_type& operator=(this_type&& x);
249+
this_type& operator=(this_type&& x);
236250
#endif
237251

238252
template <typename InputIterator>

include/EASTL/internal/char_traits.h

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,64 @@ namespace eastl
271271
return pDestination + (pSourceEnd - pSource);
272272
}
273273

274+
template <typename T>
275+
const T* CharTypeStringFindEnd(const T* pBegin, const T* pEnd, T c)
276+
{
277+
const T* pTemp = pEnd;
278+
while(--pTemp >= pBegin)
279+
{
280+
if(*pTemp == c)
281+
return pTemp;
282+
}
283+
284+
return pEnd;
285+
}
286+
287+
template <typename T>
288+
const T* CharTypeStringRSearch(const T* p1Begin, const T* p1End,
289+
const T* p2Begin, const T* p2End)
290+
{
291+
// Test for zero length strings, in which case we have a match or a failure,
292+
// but the return value is the same either way.
293+
if((p1Begin == p1End) || (p2Begin == p2End))
294+
return p1Begin;
295+
296+
// Test for a pattern of length 1.
297+
if((p2Begin + 1) == p2End)
298+
return CharTypeStringFindEnd(p1Begin, p1End, *p2Begin);
299+
300+
// Test for search string length being longer than string length.
301+
if((p2End - p2Begin) > (p1End - p1Begin))
302+
return p1End;
303+
304+
// General case.
305+
const T* pSearchEnd = (p1End - (p2End - p2Begin) + 1);
306+
const T* pCurrent1;
307+
const T* pCurrent2;
308+
309+
while(pSearchEnd != p1Begin)
310+
{
311+
// Search for the last occurrence of *p2Begin.
312+
pCurrent1 = CharTypeStringFindEnd(p1Begin, pSearchEnd, *p2Begin);
313+
if(pCurrent1 == pSearchEnd) // If the first char of p2 wasn't found,
314+
return p1End; // then we immediately have failure.
315+
316+
// In this case, *pTemp == *p2Begin. So compare the rest.
317+
pCurrent2 = p2Begin;
318+
while(*pCurrent1++ == *pCurrent2++)
319+
{
320+
if(pCurrent2 == p2End)
321+
return (pCurrent1 - (p2End - p2Begin));
322+
}
323+
324+
// A smarter algorithm might know to subtract more than just one,
325+
// but in most cases it won't make much difference anyway.
326+
--pSearchEnd;
327+
}
328+
329+
return p1End;
330+
}
331+
274332
template <typename T>
275333
inline const T* CharTypeStringFindFirstOf(const T* p1Begin, const T* p1End, const T* p2Begin, const T* p2End)
276334
{

include/EASTL/internal/config.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@
105105
///////////////////////////////////////////////////////////////////////////////
106106

107107
#ifndef EASTL_VERSION
108-
#define EASTL_VERSION "3.05.00"
109-
#define EASTL_VERSION_N 30500
108+
#define EASTL_VERSION "3.05.02"
109+
#define EASTL_VERSION_N 30502
110110
#endif
111111

112112

include/EASTL/internal/hashtable.h

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,19 @@ namespace eastl
112112
template <typename Value, bool bCacheHashCode>
113113
struct hash_node;
114114

115-
EA_DISABLE_VC_WARNING(4625) // disable warning: "copy constructor could not be generated because a base class copy constructor is inaccessible or deleted"
115+
EA_DISABLE_VC_WARNING(4625 4626) // "copy constructor / assignment operator could not be generated because a base class copy constructor is inaccessible or deleted"
116116
#ifdef EA_COMPILER_MSVC_2015
117117
EA_DISABLE_VC_WARNING(5026) // disable warning: "move constructor was implicitly defined as deleted"
118118
#endif
119119
template <typename Value>
120120
struct hash_node<Value, true>
121121
{
122+
#if defined(_MSC_VER) && (EA_COMPILER_VERSION == 1800) // VS2013
123+
hash_node(hash_node&& x) : mValue(eastl::move(x.mValue)), mpNext(x.mpNext), mnHashCode(x.mnHashCode) {}
124+
#elif EASTL_MOVE_SEMANTICS_ENABLED && !defined(EA_COMPILER_NO_DEFAULTED_FUNCTIONS)
125+
hash_node(hash_node&&) = default;
126+
#endif
127+
122128
Value mValue;
123129
hash_node* mpNext;
124130
eastl_size_t mnHashCode; // See config.h for the definition of eastl_size_t, which defaults to uint32_t.
@@ -127,7 +133,13 @@ namespace eastl
127133
template <typename Value>
128134
struct hash_node<Value, false>
129135
{
130-
Value mValue;
136+
#if defined(_MSC_VER) && (EA_COMPILER_VERSION == 1800) // VS2013
137+
hash_node(hash_node&& x) : mValue(eastl::move(x.mValue)), mpNext(x.mpNext) {}
138+
#elif EASTL_MOVE_SEMANTICS_ENABLED && !defined(EA_COMPILER_NO_DEFAULTED_FUNCTIONS)
139+
hash_node(hash_node&&) = default;
140+
#endif
141+
142+
Value mValue;
131143
hash_node* mpNext;
132144
} EASTL_MAY_ALIAS;
133145

@@ -1517,20 +1529,15 @@ namespace eastl
15171529
typename H1, typename H2, typename H, typename RP, bool bC, bool bM, bool bU>
15181530
void hashtable<K, V, A, EK, Eq, H1, H2, H, RP, bC, bM, bU>::swap(this_type& x)
15191531
{
1520-
if(mAllocator == x.mAllocator) // If allocators are equivalent...
1521-
{
1522-
// We leave mAllocator as-is.
1523-
hash_code_base<K, V, EK, Eq, H1, H2, H, bC>::base_swap(x); // hash_code_base has multiple implementations, so we let them handle the swap.
1524-
eastl::swap(mRehashPolicy, x.mRehashPolicy);
1525-
EASTL_MACRO_SWAP(node_type**, mpBucketArray, x.mpBucketArray); // Use EASTL_MACRO_SWAP because GCC (at least v4.6-4.8) has a bug where it fails to compile eastl::swap(mpBucketArray, x.mpBucketArray).
1526-
eastl::swap(mnBucketCount, x.mnBucketCount);
1527-
eastl::swap(mnElementCount, x.mnElementCount);
1528-
}
1529-
else
1532+
hash_code_base<K, V, EK, Eq, H1, H2, H, bC>::base_swap(x); // hash_code_base has multiple implementations, so we let them handle the swap.
1533+
eastl::swap(mRehashPolicy, x.mRehashPolicy);
1534+
eastl::swap(mpBucketArray, x.mpBucketArray);
1535+
eastl::swap(mnBucketCount, x.mnBucketCount);
1536+
eastl::swap(mnElementCount, x.mnElementCount);
1537+
1538+
if (mAllocator != x.mAllocator) // If allocators are not equivalent...
15301539
{
1531-
const this_type temp(*this); // Can't call eastl::swap because that would
1532-
*this = x; // itself call this member swap function.
1533-
x = temp;
1540+
eastl::swap(mAllocator, x.mAllocator);
15341541
}
15351542
}
15361543

include/EASTL/iterator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ namespace eastl
468468
move_iterator operator++(int)
469469
{
470470
move_iterator tempMoveIterator = *this;
471-
++tempMoveIterator;
471+
++mIterator;
472472
return tempMoveIterator;
473473
}
474474

@@ -481,7 +481,7 @@ namespace eastl
481481
move_iterator operator--(int)
482482
{
483483
move_iterator tempMoveIterator = *this;
484-
--tempMoveIterator;
484+
--mIterator;
485485
return tempMoveIterator;
486486
}
487487

include/EASTL/string_view.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ namespace eastl
3838
typedef const T* const_iterator;
3939
typedef eastl::reverse_iterator<iterator> reverse_iterator;
4040
typedef eastl::reverse_iterator<const_iterator> const_reverse_iterator;
41-
typedef eastl_size_t size_type;
41+
typedef size_t size_type;
4242
typedef ptrdiff_t difference_type;
4343

4444
static const EA_CONSTEXPR size_type npos = size_type(-1);
@@ -60,10 +60,10 @@ namespace eastl
6060
EA_CONSTEXPR const_iterator cbegin() const EA_NOEXCEPT { return mpBegin; }
6161
EA_CONSTEXPR const_iterator end() const EA_NOEXCEPT { return mpBegin + mnCount; }
6262
EA_CONSTEXPR const_iterator cend() const EA_NOEXCEPT { return mpBegin + mnCount; }
63-
EA_CONSTEXPR const_reverse_iterator rbegin() const EA_NOEXCEPT { return reverse_iterator(mpBegin + mnCount); }
64-
EA_CONSTEXPR const_reverse_iterator crbegin() const EA_NOEXCEPT { return reverse_iterator(mpBegin + mnCount); }
65-
EA_CONSTEXPR const_reverse_iterator rend() const EA_NOEXCEPT { return reverse_iterator(mpBegin); }
66-
EA_CONSTEXPR const_reverse_iterator crend() const EA_NOEXCEPT { return reverse_iterator(mpBegin); }
63+
EA_CONSTEXPR const_reverse_iterator rbegin() const EA_NOEXCEPT { return const_reverse_iterator(mpBegin + mnCount); }
64+
EA_CONSTEXPR const_reverse_iterator crbegin() const EA_NOEXCEPT { return const_reverse_iterator(mpBegin + mnCount); }
65+
EA_CONSTEXPR const_reverse_iterator rend() const EA_NOEXCEPT { return const_reverse_iterator(mpBegin); }
66+
EA_CONSTEXPR const_reverse_iterator crend() const EA_NOEXCEPT { return const_reverse_iterator(mpBegin); }
6767

6868

6969
// 21.4.2.4, element access

include/EASTL/type_traits.h

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -629,13 +629,35 @@ namespace eastl
629629
struct is_function
630630
: public eastl::false_type {};
631631

632-
template <typename ReturnValue, typename... ArgPack>
633-
struct is_function<ReturnValue /*FunctionName*/(ArgPack...)>
634-
: public eastl::true_type {};
635-
636-
template <typename ReturnValue, typename... ArgPack>
637-
struct is_function<ReturnValue /*FunctionName*/(ArgPack..., ...)> // The second ellipsis handles the case of a function that takes ellipsis, like printf.
638-
: public eastl::true_type {};
632+
#if EA_PLATFORM_PTR_SIZE == 4 && defined(EA_PLATFORM_MICROSOFT) && defined(_MSC_EXTENSIONS)
633+
// __cdecl specialization
634+
template <typename ReturnValue, typename... ArgPack>
635+
struct is_function<ReturnValue __cdecl (ArgPack...)>
636+
: public eastl::true_type {};
637+
638+
template <typename ReturnValue, typename... ArgPack>
639+
struct is_function<ReturnValue __cdecl (ArgPack..., ...)> // The second ellipsis handles the case of a function that takes ellipsis, like printf.
640+
: public eastl::true_type {};
641+
642+
// __stdcall specialization
643+
template <typename ReturnValue, typename... ArgPack>
644+
struct is_function<ReturnValue __stdcall (ArgPack...)>
645+
: public eastl::true_type {};
646+
647+
// When functions use a variable number of arguments, it is the caller that cleans the stack (cf. cdecl).
648+
//
649+
// template <typename ReturnValue, typename... ArgPack>
650+
// struct is_function<ReturnValue __stdcall (ArgPack..., ...)> // The second ellipsis handles the case of a function that takes ellipsis, like printf.
651+
// : public eastl::true_type {};
652+
#else
653+
template <typename ReturnValue, typename... ArgPack>
654+
struct is_function<ReturnValue (ArgPack...)>
655+
: public eastl::true_type {};
656+
657+
template <typename ReturnValue, typename... ArgPack>
658+
struct is_function<ReturnValue (ArgPack..., ...)> // The second ellipsis handles the case of a function that takes ellipsis, like printf.
659+
: public eastl::true_type {};
660+
#endif
639661
#endif
640662

641663

include/EASTL/unordered_map.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright (c) Electronic Arts Inc. All rights reserved.
3+
///////////////////////////////////////////////////////////////////////////////
4+
5+
#ifndef EASTL_UNORDERED_MAP_H
6+
#define EASTL_UNORDERED_MAP_H
7+
8+
#include <EASTL/internal/config.h>
9+
#include <EASTL/hash_map.h>
10+
11+
EA_ONCE()
12+
13+
namespace eastl
14+
{
15+
/// unordered_map
16+
///
17+
/// The original TR1 (technical report 1) used "hash_map" to name a hash
18+
/// table backed associative container of unique key-value pairs. When the
19+
/// container was added to the C++11 standard the committee chose the name
20+
/// "unordered_map" to clarify that internally the elements are NOT sorted in
21+
/// any particular order. We provide a template alias here to ensure feature
22+
/// parity with the original eastl::hash_map.
23+
///
24+
#if !defined(EA_COMPILER_NO_TEMPLATE_ALIASES)
25+
template <typename Key,
26+
typename T,
27+
typename Hash = eastl::hash<Key>,
28+
typename Predicate = eastl::equal_to<Key>,
29+
typename Allocator = EASTLAllocatorType,
30+
bool bCacheHashCode = false>
31+
using unordered_map = hash_map<Key, T, Hash, Predicate, Allocator, bCacheHashCode>;
32+
#endif
33+
34+
/// unordered_multimap
35+
///
36+
/// Similar template alias as "unordered_map" except the contained elements
37+
/// need not be unique. See "hash_multimap" for more details.
38+
///
39+
#if !defined(EA_COMPILER_NO_TEMPLATE_ALIASES)
40+
template <typename Key,
41+
typename T,
42+
typename Hash = eastl::hash<Key>,
43+
typename Predicate = eastl::equal_to<Key>,
44+
typename Allocator = EASTLAllocatorType,
45+
bool bCacheHashCode = false>
46+
using unordered_multimap = hash_multimap<Key, T, Hash, Predicate, Allocator, bCacheHashCode>;
47+
#endif
48+
49+
} // namespace eastl
50+
51+
#endif // Header include guard
52+

0 commit comments

Comments
 (0)