Skip to content

Commit a6f87f3

Browse files
committed
blah
1 parent e3b861a commit a6f87f3

File tree

9 files changed

+659
-2
lines changed

9 files changed

+659
-2
lines changed

src/ea/EABase

src/ea/EASTL

Submodule EASTL updated from ce460c0 to 6629b24

src/ea/include/__EASTL_user_config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
#define _EASTL_USER_CONFIG_H
33

44

5+
#ifndef EASTL_ALLOCATOR_COPY_ENABLED
6+
// TODO
7+
// #define EASTL_ALLOCATOR_COPY_ENABLED 1
8+
#endif
9+
510
#define EASTL_THREAD_SUPPORT_AVAILABLE 0
611

712

src/ea/makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ WILDCARD_EASTL_INTERNAL_H := $(wildcard EASTL/include/EASTL/internal/*.h)
3535
# WILDCARD_EASTL_INTERNAL_ATOMIC_H := $(wildcard EASTL/include/EASTL/internal/atomic/*.h)
3636
WILDCARD_EABASE_H := $(wildcard EABase/include/Common/EABase/*.h)
3737
WILDCARD_EABASE_CONFIG_H := $(wildcard EABase/include/Common/EABase/config/*.h)
38+
WILDCARD_STL_H := $(wildcard stl/include/*)
3839

3940
all: $(BUILD_SRC)
4041

@@ -66,5 +67,6 @@ install: all
6667
$(Q)$(call COPY,$(foreach file,$(call NATIVEPATH,$(WILDCARD_EABASE_CONFIG_H)),$(call QUOTE_ARG,$(file))),$(INSTALL_EABASE_CONFIG_H))
6768
$(Q)$(call COPY,$(foreach file,$(call NATIVEPATH,$(WILDCARD_EABASE_H)),$(call QUOTE_ARG,$(file))),$(INSTALL_EABASE_H))
6869
$(Q)$(call COPY,$(foreach file,$(call NATIVEPATH,$(CONFIG_H)),$(call QUOTE_ARG,$(file))),$(INSTALL_H))
70+
$(Q)$(call COPY,$(foreach file,$(call NATIVEPATH,$(WILDCARD_STL_H)),$(call QUOTE_ARG,$(file))),$(INSTALL_H))
6971

7072
.PHONY: all clean
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#pragma once
2+
3+
#include <EASTL/internal/config.h>
4+
5+
#include <EASTL/allocator.h>
6+
7+
#include <memory>
8+
#include <type_traits>
9+
#include <utility>
10+
11+
12+
namespace std::ea {
13+
14+
template <class StdAllocator, class = void>
15+
class allocator_adapter
16+
{
17+
// TODO
18+
};
19+
20+
template <class StdAllocator>
21+
class allocator_adapter<StdAllocator, std::void_t<std::declval<StdAllocator&>().get_eastl_allocator()>>
22+
: protected StdAllocator
23+
{
24+
typedef StdAllocator base_type;
25+
26+
public:
27+
EA_CPP20_CONSTEXPR allocator_adapter() EA_CPP11_NOEXCEPT_THROW {}
28+
EA_CPP20_CONSTEXPR allocator_adapter(const StdAllocator& alloc) EA_CPP11_NOEXCEPT_THROW
29+
: base_type(alloc)
30+
{}
31+
EA_CPP20_CONSTEXPR allocator_adapter(const allocator_adapter& other) EA_CPP11_NOEXCEPT_THROW
32+
: base_type(other.get_std_allocator())
33+
{}
34+
35+
void* allocate(size_t n, int flags = 0) {
36+
return get_eastl_allocator().allocate(n, flags);
37+
}
38+
void* allocate(size_t n, size_t alignment, size_t offset, int flags = 0) {
39+
return get_eastl_allocator().allocate(n, alignment, offset, flags);
40+
}
41+
void deallocate(void* p, size_t n) {
42+
get_eastl_allocator().deallocate(p, n);
43+
}
44+
45+
const char* get_name() const {
46+
return get_eastl_allocator().get_name();
47+
}
48+
void set_name(const char* pName) {
49+
get_eastl_allocator().set_name(pName);
50+
}
51+
52+
constexpr StdAllocator& get_std_allocator() noexcept { return *this; }
53+
constexpr const StdAllocator& get_std_allocator() const noexcept { return *this; }
54+
};
55+
56+
template <class T1, class T2>
57+
constexpr bool operator==(const allocator_adapter<T1>& a, const allocator_adapter<T2>& b) noexcept
58+
{
59+
return a.get_std_allocator() == b.get_std_allocator();
60+
}
61+
#if __cplusplus < 202002L
62+
template <class T1, class T2>
63+
constexpr bool operator!=(const allocator_adapter<T1>& a, const allocator_adapter<T2>& b) noexcept
64+
{
65+
return a.get_std_allocator() != b.get_std_allocator();
66+
}
67+
#endif
68+
69+
} // namespace std::ea

src/ea/stl/include/iterator

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#pragma once
2+
3+
#include <EASTL/internal/config.h>
4+
5+
#include <EASTL/iterator.h>
6+
7+
#include <utility>
8+
9+
10+
namespace std {
11+
12+
template <class Iter>
13+
class reverse_iterator : public eastl::reverse_iterator<Iter> {
14+
typedef eastl::reverse_iterator<Iter> base_type;
15+
16+
public:
17+
typedef typename base_type::iterator_type iterator_type;
18+
typedef typename base_type::value_type value_type;
19+
typedef typename base_type::difference_type difference_type;
20+
typedef typename base_type::pointer pointer;
21+
typedef typename base_type::reference reference;
22+
typedef typename base_type::iterator_category iterator_category;
23+
// TODO(C++20): iterator_concept and member type changes
24+
25+
EA_CPP17_CONSTEXPR reverse_iterator() {}
26+
EA_CPP17_CONSTEXPR explicit reverse_iterator(iterator_type x)
27+
: base_type(x)
28+
{}
29+
template <class U>
30+
EA_CPP17_CONSTEXPR reverse_iterator(const reverse_iterator<U>& other)
31+
: base_type(other.base())
32+
{}
33+
34+
template <class U>
35+
EA_CPP17_CONSTEXPR reverse_iterator& operator=(const reverse_iterator<U>& other)
36+
{
37+
base_type::operator=(other.base());
38+
return *this;
39+
}
40+
41+
using base_type::base;
42+
43+
using base_type::operator*;
44+
using base_type::operator->;
45+
46+
using base_type::operator[];
47+
48+
using base_type::operator++;
49+
using base_type::operator+=;
50+
using base_type::operator+;
51+
using base_type::operator--;
52+
using base_type::operator-=;
53+
using base_type::operator-;
54+
};
55+
56+
template <class Iterator1, class Iterator2>
57+
EA_CPP17_CONSTEXPR bool operator==(const std::reverse_iterator<Iterator1>& lhs, const std::reverse_iterator<Iterator2>& rhs)
58+
{
59+
return lhs.base() == rhs.base();
60+
}
61+
template <class Iterator1, class Iterator2>
62+
EA_CPP17_CONSTEXPR bool operator!=(const std::reverse_iterator<Iterator1>& lhs, const std::reverse_iterator<Iterator2>& rhs)
63+
{
64+
return lhs.base() != rhs.base();
65+
}
66+
template <class Iterator1, class Iterator2>
67+
EA_CPP17_CONSTEXPR bool operator<(const std::reverse_iterator<Iterator1>& lhs, const std::reverse_iterator<Iterator2>& rhs)
68+
{
69+
return lhs.base() > rhs.base();
70+
}
71+
template <class Iterator1, class Iterator2>
72+
EA_CPP17_CONSTEXPR bool operator<=(const std::reverse_iterator<Iterator1>& lhs, const std::reverse_iterator<Iterator2>& rhs)
73+
{
74+
return lhs.base() >= rhs.base();
75+
}
76+
template <class Iterator1, class Iterator2>
77+
EA_CPP17_CONSTEXPR bool operator>(const std::reverse_iterator<Iterator1>& lhs, const std::reverse_iterator<Iterator2>& rhs)
78+
{
79+
return lhs.base() < rhs.base();
80+
}
81+
template <class Iterator1, class Iterator2>
82+
EA_CPP17_CONSTEXPR bool operator>=(const std::reverse_iterator<Iterator1>& lhs, const std::reverse_iterator<Iterator2>& rhs)
83+
{
84+
return lhs.base() <= rhs.base();
85+
}
86+
// TODO(C++20): operator<=>
87+
88+
template <class Iter>
89+
EA_CPP17_CONSTEXPR std::reverse_iterator<Iter> operator+(
90+
typename std::reverse_iterator<Iter>::difference_type n,
91+
const std::reverse_iterator<Iter>& it)
92+
{
93+
return it + n;
94+
}
95+
96+
template <class Iterator1, class Iterator2>
97+
#if __cplusplus >= 201103L
98+
EA_CPP17_CONSTEXPR auto
99+
#else
100+
typename std::reverse_iterator<Iterator1>::difference_type
101+
#endif
102+
operator-(const std::reverse_iterator<Iterator1>& lhs, const std::reverse_iterator<Iterator2>& rhs)
103+
#if __cplusplus >= 201103L
104+
-> decltype(rhs.base() - lhs.base())
105+
#endif
106+
{
107+
return rhs.base() - lhs.base();
108+
}
109+
110+
// TODO(C++20): iter_move
111+
112+
// TODO(C++20): iter_swap
113+
114+
template <class Iter>
115+
EA_CPP17_CONSTEXPR std::reverse_iterator<Iter> make_reverse_iterator(Iter i)
116+
{
117+
return std::reverse_iterator<Iter>(i);
118+
}
119+
120+
} // namespace std

0 commit comments

Comments
 (0)