Skip to content

Commit db16065

Browse files
authored
Merge pull request electronicarts#493 from electronicarts/eastl-3.19.05
Update to 13.19.05
2 parents 19a8869 + 384db67 commit db16065

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+975
-396
lines changed

include/EASTL/algorithm.h

Lines changed: 91 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@
164164
// random_shuffle<Random>
165165
// remove
166166
// remove_if
167+
// +apply_and_remove
168+
// +apply_and_remove_if
167169
// remove_copy
168170
// remove_copy_if
169171
// +remove_heap Found in heap.h
@@ -1261,14 +1263,8 @@ namespace eastl
12611263
inline BidirectionalIterator2 move_and_copy_backward_chooser(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 resultEnd)
12621264
{
12631265
typedef typename eastl::iterator_traits<BidirectionalIterator1>::iterator_category IIC;
1264-
typedef typename eastl::iterator_traits<BidirectionalIterator2>::iterator_category OIC;
1265-
typedef typename eastl::iterator_traits<BidirectionalIterator1>::value_type value_type_input;
1266-
typedef typename eastl::iterator_traits<BidirectionalIterator2>::value_type value_type_output;
12671266

1268-
const bool canBeMemmoved = eastl::is_trivially_copyable<value_type_output>::value &&
1269-
eastl::is_same<value_type_input, value_type_output>::value &&
1270-
(eastl::is_pointer<BidirectionalIterator1>::value || eastl::is_same<IIC, EASTL_ITC_NS::contiguous_iterator_tag>::value) &&
1271-
(eastl::is_pointer<BidirectionalIterator2>::value || eastl::is_same<OIC, EASTL_ITC_NS::contiguous_iterator_tag>::value);
1267+
const bool canBeMemmoved = internal::can_be_memmoved_helper<BidirectionalIterator1, BidirectionalIterator2>::value;
12721268

12731269
return eastl::move_and_copy_backward_helper<IIC, isMove, canBeMemmoved>::move_or_copy_backward(first, last, resultEnd); // Need to chose based on the input iterator tag and not the output iterator tag, because containers accept input ranges of iterator types different than self.
12741270
}
@@ -2666,6 +2662,94 @@ namespace eastl
26662662
}
26672663

26682664

2665+
/// apply_and_remove_if
2666+
///
2667+
/// Calls the Function function for all elements referred to my iterator i in the range
2668+
/// [first, last) for which the following corresponding condition holds:
2669+
/// predicate(*i) == true
2670+
/// and then left shift moves potential non-matching elements over it.
2671+
///
2672+
/// Returns: a past-the-end iterator for the new end of the range.
2673+
///
2674+
/// Complexity: Exactly 'last - first' applications of the corresponding predicate + applies
2675+
/// function once for every time the condition holds.
2676+
///
2677+
/// Note: Since removing is done by shifting (by means of copy move assignment) the elements
2678+
/// in the range in such a way that the elements that are not to be removed appear in the
2679+
/// beginning of the range doesn't actually remove it from the given container, the user must call
2680+
/// the container erase function if the user wants to erase the element
2681+
/// from the container. I.e. in the same they as for remove_if the excess elements
2682+
/// are left in a valid but possibly moved from state.
2683+
///
2684+
template <typename ForwardIterator, typename Function, typename Predicate>
2685+
inline ForwardIterator apply_and_remove_if(ForwardIterator first,
2686+
ForwardIterator last,
2687+
Function function,
2688+
Predicate predicate)
2689+
{
2690+
first = eastl::find_if(first, last, predicate);
2691+
if (first != last)
2692+
{
2693+
function(*first);
2694+
for (auto i = next(first); i != last; ++i)
2695+
{
2696+
if (predicate(*i))
2697+
{
2698+
function(*i);
2699+
continue;
2700+
}
2701+
*first = eastl::move(*i);
2702+
++first;
2703+
}
2704+
}
2705+
return first;
2706+
}
2707+
2708+
2709+
/// apply_and_remove
2710+
///
2711+
/// Calls the Function function for all elements referred to my iterator i in the range
2712+
/// [first, last) for which the following corresponding condition holds:
2713+
/// value == *i
2714+
/// and then left shift moves potential non-matching elements over it.
2715+
///
2716+
/// Returns: a past-the-end iterator for the new end of the range.
2717+
///
2718+
/// Complexity: Exactly 'last - first' applications of the corresponding equality test
2719+
/// + applies function once for every time the condition holds.
2720+
///
2721+
/// Note: Since removing is done by shifting (by means of copy move assignment) the elements
2722+
/// in the range in such a way that the elements that are not to be removed appear in the
2723+
/// beginning of the range doesn't actually remove it from the given container, the user must call
2724+
/// the container erase function if the user wants to erase the element
2725+
/// from the container. I.e. in the same they as for remove_if the excess elements
2726+
/// are left in a valid but possibly moved from state.
2727+
///
2728+
template <typename ForwardIterator, typename Function, typename T>
2729+
inline ForwardIterator apply_and_remove(ForwardIterator first,
2730+
ForwardIterator last,
2731+
Function function,
2732+
const T& value)
2733+
{
2734+
first = eastl::find(first, last, value);
2735+
if (first != last)
2736+
{
2737+
function(*first);
2738+
for (auto i = next(first); i != last; ++i)
2739+
{
2740+
if (value == *i)
2741+
{
2742+
function(*i);
2743+
continue;
2744+
}
2745+
*first = eastl::move(*i);
2746+
++first;
2747+
}
2748+
}
2749+
return first;
2750+
}
2751+
2752+
26692753
/// replace_copy
26702754
///
26712755
/// Effects: Assigns to every iterator i in the range [result, result + (last - first))

include/EASTL/bonus/lru_cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ namespace eastl
122122
}
123123

124124
lru_cache(std::initializer_list<eastl::pair<Key, Value>> il)
125-
: lru_cache(il.size())
125+
: lru_cache(static_cast<size_type>(il.size()))
126126
{
127127
for(auto& p : il)
128128
insert_or_assign(p.first, p.second);

include/EASTL/chrono.h

Lines changed: 44 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#define EASTL_CHRONO_H
1717

1818
#if defined(EA_PRAGMA_ONCE_SUPPORTED)
19-
#pragma once
19+
#pragma once
2020
#endif
2121

2222
#include <EASTL/internal/config.h>
@@ -52,7 +52,7 @@
5252
// Nothing to do
5353
#elif defined(EA_PLATFORM_APPLE)
5454
#include <mach/mach_time.h>
55-
#elif defined(EA_PLATFORM_POSIX) || defined(EA_PLATFORM_MINGW) || defined(EA_PLATFORM_ANDROID)
55+
#elif defined(EA_PLATFORM_POSIX) || defined(EA_PLATFORM_MINGW) || defined(EA_PLATFORM_ANDROID)
5656
// Posix means Linux, Unix, and Macintosh OSX, among others (including Linux-based mobile platforms).
5757
#if defined(EA_PLATFORM_MINGW)
5858
#include <pthread_time.h>
@@ -101,7 +101,7 @@ namespace chrono
101101
namespace Internal
102102
{
103103
///////////////////////////////////////////////////////////////////////////////
104-
// IsRatio
104+
// IsRatio
105105
///////////////////////////////////////////////////////////////////////////////
106106
template <typename> struct IsRatio : eastl::false_type {};
107107
template <intmax_t N, intmax_t D> struct IsRatio<ratio<N, D>> : eastl::true_type {};
@@ -111,7 +111,7 @@ namespace chrono
111111

112112

113113
///////////////////////////////////////////////////////////////////////////////
114-
// IsDuration
114+
// IsDuration
115115
///////////////////////////////////////////////////////////////////////////////
116116
template<typename> struct IsDuration : eastl::false_type{};
117117
template<typename Rep, typename Period> struct IsDuration<duration<Rep, Period>> : eastl::true_type{};
@@ -121,7 +121,7 @@ namespace chrono
121121

122122

123123
///////////////////////////////////////////////////////////////////////////////
124-
// RatioGCD
124+
// RatioGCD
125125
///////////////////////////////////////////////////////////////////////////////
126126
template <class Period1, class Period2>
127127
struct RatioGCD
@@ -194,10 +194,10 @@ namespace chrono
194194

195195

196196
///////////////////////////////////////////////////////////////////////////////
197-
// duration_cast
197+
// duration_cast
198198
///////////////////////////////////////////////////////////////////////////////
199199
template <typename ToDuration, typename Rep, typename Period>
200-
inline typename eastl::enable_if<Internal::IsDuration<ToDuration>::value, ToDuration>::type
200+
inline typename eastl::enable_if<Internal::IsDuration<ToDuration>::value, ToDuration>::type
201201
duration_cast(const duration<Rep, Period>& d)
202202
{
203203
typedef typename duration<Rep, Period>::this_type FromDuration;
@@ -206,20 +206,20 @@ namespace chrono
206206

207207

208208
///////////////////////////////////////////////////////////////////////////////
209-
// duration
209+
// duration
210210
///////////////////////////////////////////////////////////////////////////////
211211
template <class Rep, class Period>
212212
class duration
213213
{
214-
Rep mRep;
214+
Rep mRep;
215215

216216
public:
217217
typedef Rep rep;
218218
typedef Period period;
219219
typedef duration<Rep, Period> this_type;
220220

221221
#if defined(EA_COMPILER_NO_DEFAULTED_FUNCTIONS)
222-
EA_CONSTEXPR duration()
222+
EA_CONSTEXPR duration()
223223
: mRep() {}
224224

225225
duration(const duration& other)
@@ -235,7 +235,7 @@ namespace chrono
235235

236236

237237
///////////////////////////////////////////////////////////////////////////////
238-
// conversion constructors
238+
// conversion constructors
239239
///////////////////////////////////////////////////////////////////////////////
240240
template <class Rep2>
241241
inline EA_CONSTEXPR explicit duration(
@@ -255,12 +255,12 @@ namespace chrono
255255
: mRep(duration_cast<duration>(d2).count()) {}
256256

257257
///////////////////////////////////////////////////////////////////////////////
258-
// returns the count of ticks
258+
// returns the count of ticks
259259
///////////////////////////////////////////////////////////////////////////////
260260
EA_CONSTEXPR Rep count() const { return mRep; }
261261

262262
///////////////////////////////////////////////////////////////////////////////
263-
// static accessors of special duration values
263+
// static accessors of special duration values
264264
///////////////////////////////////////////////////////////////////////////////
265265
EA_CONSTEXPR inline static duration zero() { return duration(duration_values<Rep>::zero()); }
266266
EA_CONSTEXPR inline static duration min() { return duration(duration_values<Rep>::min()); }
@@ -418,7 +418,7 @@ namespace chrono
418418
///////////////////////////////////////////////////////////////////////////////
419419
// 20.12.6, time_point
420420
///////////////////////////////////////////////////////////////////////////////
421-
template <typename Clock, typename Duration = typename Clock::duration>
421+
template <typename Clock, typename Duration = typename Clock::duration>
422422
class time_point
423423
{
424424
Duration mDuration;
@@ -440,7 +440,7 @@ namespace chrono
440440

441441
EA_CONSTEXPR Duration time_since_epoch() const { return mDuration; }
442442

443-
time_point& operator+=(const Duration& d) { mDuration += d; return *this; }
443+
time_point& operator+=(const Duration& d) { mDuration += d; return *this; }
444444
time_point& operator-=(const Duration& d) { mDuration -= d; return *this; }
445445

446446
static EA_CONSTEXPR time_point min() { return time_point(Duration::min()); }
@@ -543,7 +543,7 @@ namespace chrono
543543
namespace Internal
544544
{
545545
#if defined(EA_PLATFORM_MICROSOFT) && !defined(EA_PLATFORM_MINGW)
546-
#define EASTL_NS_PER_TICK 1
546+
#define EASTL_NS_PER_TICK 1
547547
#elif defined EA_PLATFORM_SONY
548548
#define EASTL_NS_PER_TICK 1
549549
#elif defined EA_PLATFORM_POSIX
@@ -552,17 +552,17 @@ namespace chrono
552552
#define EASTL_NS_PER_TICK 100
553553
#endif
554554

555-
#if defined(EA_PLATFORM_POSIX)
555+
#if defined(EA_PLATFORM_POSIX)
556556
typedef chrono::nanoseconds::period SystemClock_Period;
557557
typedef chrono::nanoseconds::period SteadyClock_Period;
558558
#else
559-
typedef eastl::ratio_multiply<eastl::ratio<EASTL_NS_PER_TICK, 1>, nano>::type SystemClock_Period;
560-
typedef eastl::ratio_multiply<eastl::ratio<EASTL_NS_PER_TICK, 1>, nano>::type SteadyClock_Period;
559+
typedef eastl::ratio_multiply<eastl::ratio<EASTL_NS_PER_TICK, 1>, nano>::type SystemClock_Period;
560+
typedef eastl::ratio_multiply<eastl::ratio<EASTL_NS_PER_TICK, 1>, nano>::type SteadyClock_Period;
561561
#endif
562562

563563

564564
///////////////////////////////////////////////////////////////////////////////
565-
// Internal::GetTicks
565+
// Internal::GetTicks
566566
///////////////////////////////////////////////////////////////////////////////
567567
inline uint64_t GetTicks()
568568
{
@@ -595,7 +595,7 @@ namespace chrono
595595
mach_timebase_info(&info);
596596
return info;
597597
};
598-
598+
599599
static auto timeInfo = queryTimeInfo();
600600
uint64_t t = mach_absolute_time();
601601
t *= timeInfo.numer;
@@ -625,7 +625,7 @@ namespace chrono
625625

626626

627627
///////////////////////////////////////////////////////////////////////////////
628-
// system_clock
628+
// system_clock
629629
///////////////////////////////////////////////////////////////////////////////
630630
class system_clock
631631
{
@@ -639,15 +639,15 @@ namespace chrono
639639
EA_CONSTEXPR_OR_CONST static bool is_steady = false;
640640

641641
// returns a time point representing the current point in time.
642-
static time_point now() EA_NOEXCEPT
643-
{
644-
return time_point(duration(Internal::GetTicks()));
642+
static time_point now() EA_NOEXCEPT
643+
{
644+
return time_point(duration(Internal::GetTicks()));
645645
}
646646
};
647647

648648

649649
///////////////////////////////////////////////////////////////////////////////
650-
// steady_clock
650+
// steady_clock
651651
///////////////////////////////////////////////////////////////////////////////
652652
class steady_clock
653653
{
@@ -661,24 +661,24 @@ namespace chrono
661661
EA_CONSTEXPR_OR_CONST static bool is_steady = true;
662662

663663
// returns a time point representing the current point in time.
664-
static time_point now() EA_NOEXCEPT
665-
{
666-
return time_point(duration(Internal::GetTicks()));
664+
static time_point now() EA_NOEXCEPT
665+
{
666+
return time_point(duration(Internal::GetTicks()));
667667
}
668668
};
669669

670670

671671
///////////////////////////////////////////////////////////////////////////////
672-
// high_resolution_clock
672+
// high_resolution_clock
673673
///////////////////////////////////////////////////////////////////////////////
674674
typedef system_clock high_resolution_clock;
675675

676676

677-
} // namespace chrono
677+
} // namespace chrono
678678

679679

680680
///////////////////////////////////////////////////////////////////////////////
681-
// duration common_type specialization
681+
// duration common_type specialization
682682
///////////////////////////////////////////////////////////////////////////////
683683
template <typename Rep1, typename Period1, typename Rep2, typename Period2>
684684
struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>
@@ -689,7 +689,7 @@ namespace chrono
689689

690690

691691
///////////////////////////////////////////////////////////////////////////////
692-
// time_point common_type specialization
692+
// time_point common_type specialization
693693
///////////////////////////////////////////////////////////////////////////////
694694
template <typename Clock, typename Duration1, typename Duration2>
695695
struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>
@@ -699,10 +699,15 @@ namespace chrono
699699

700700

701701
///////////////////////////////////////////////////////////////////////////////
702-
// chrono_literals
702+
// chrono_literals
703703
///////////////////////////////////////////////////////////////////////////////
704704
#if EASTL_USER_LITERALS_ENABLED && EASTL_INLINE_NAMESPACES_ENABLED
705-
EA_DISABLE_VC_WARNING(4455) // disable warning C4455: literal suffix identifiers that do not start with an underscore are reserved
705+
// Disabling the Clang/GCC/MSVC warning about using user
706+
// defined literals without a leading '_' as they are reserved
707+
// for standard libary usage.
708+
EA_DISABLE_VC_WARNING(4455)
709+
EA_DISABLE_CLANG_WARNING(-Wuser-defined-literals)
710+
EA_DISABLE_GCC_WARNING(-Wliteral-suffix)
706711
inline namespace literals
707712
{
708713
inline namespace chrono_literals
@@ -735,7 +740,9 @@ namespace chrono
735740

736741
} // namespace chrono_literals
737742
}// namespace literals
738-
EA_RESTORE_VC_WARNING() // warning: 4455
743+
EA_RESTORE_GCC_WARNING() // -Wliteral-suffix
744+
EA_RESTORE_CLANG_WARNING() // -Wuser-defined-literals
745+
EA_RESTORE_VC_WARNING() // warning: 4455
739746
#endif
740747

741748
} // namespace eastl
@@ -749,4 +756,4 @@ namespace chrono
749756
#endif
750757

751758

752-
#endif
759+
#endif

0 commit comments

Comments
 (0)