Skip to content

Commit 88ce755

Browse files
committed
Merge branch 'main' into rename-include-guard
2 parents e714ac4 + 93187f6 commit 88ce755

14 files changed

Lines changed: 758 additions & 814 deletions

doc/rvariant.adoc

Lines changed: 153 additions & 229 deletions
Large diffs are not rendered by default.

doc/rvariant.html

Lines changed: 165 additions & 301 deletions
Large diffs are not rendered by default.

include/iris/hash_fwd.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
#include <version>
77

8-
#if __cplusplus <= 202302L || \
8+
#if !defined(_MSC_VER) && __cplusplus <= 202302L || \
99
(defined(_MSVC_STL_UPDATE) && _MSVC_STL_UPDATE < 202504L) || \
1010
(defined(__GLIBCXX__) && __GLIBCXX__ < 20241201) || \
1111
(defined(_LIBCPP_STD_VER) && _LIBCPP_STD_VER < 26)

include/iris/indirect.hpp

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
// SPDX-License-Identifier: MIT
55

6+
#include <iris/bits/specialization_of.hpp>
67
#include <iris/compare.hpp>
78
#include <iris/hash.hpp>
8-
#include <iris/type_traits.hpp>
99

1010
#include <compare>
1111
#include <memory>
@@ -25,13 +25,12 @@ class scoped_allocation
2525
using pointer = std::allocator_traits<Alloc>::pointer;
2626
using const_pointer = std::allocator_traits<Alloc>::const_pointer;
2727

28-
2928
template<class... Args>
30-
constexpr explicit scoped_allocation(Alloc const& a, std::in_place_t, Args&&... args)
29+
constexpr explicit scoped_allocation(Alloc const& a, Args&&... args)
3130
: alloc_(a)
3231
, ptr_(std::allocator_traits<Alloc>::allocate(alloc_, 1))
3332
{
34-
std::allocator_traits<Alloc>::construct(alloc_, get(), std::forward<Args>(args)...);
33+
std::allocator_traits<Alloc>::construct(alloc_, this->get(), std::forward<Args>(args)...);
3534
}
3635

3736
constexpr ~scoped_allocation()
@@ -70,7 +69,7 @@ class indirect_base
7069
using const_pointer = std::allocator_traits<Allocator>::const_pointer;
7170

7271
constexpr explicit indirect_base() requires std::is_default_constructible_v<Allocator>
73-
: ptr_(make_obj())
72+
: ptr_(this->make_obj())
7473
{}
7574

7675
constexpr indirect_base(indirect_base const& other)
@@ -83,12 +82,12 @@ class indirect_base
8382

8483
constexpr explicit indirect_base(std::allocator_arg_t, Allocator const& a)
8584
: alloc_(a)
86-
, ptr_(make_obj())
85+
, ptr_(this->make_obj())
8786
{}
8887

8988
constexpr indirect_base(std::allocator_arg_t, Allocator const& a, indirect_base const& other)
9089
: alloc_(a)
91-
, ptr_(other.ptr_ ? make_obj(std::as_const(*other.ptr_)) : nullptr)
90+
, ptr_(other.ptr_ ? this->make_obj(std::as_const(*other.ptr_)) : nullptr)
9291
{
9392
static_assert(std::is_copy_constructible_v<T>);
9493
}
@@ -103,7 +102,7 @@ class indirect_base
103102
: alloc_(a)
104103
, ptr_(alloc_ == other.alloc_
105104
? std::exchange(other.ptr_, nullptr)
106-
: make_obj(*std::move(other))
105+
: this->make_obj(*std::move(other))
107106
)
108107
{}
109108

@@ -114,7 +113,7 @@ class indirect_base
114113
std::is_constructible_v<T, U> &&
115114
std::is_default_constructible_v<Allocator>
116115
constexpr explicit indirect_base(U&& u)
117-
: ptr_(make_obj(std::forward<U>(u)))
116+
: ptr_(this->make_obj(std::forward<U>(u)))
118117
{}
119118

120119
template<class U = T>
@@ -124,45 +123,45 @@ class indirect_base
124123
std::is_constructible_v<T, U>
125124
constexpr explicit indirect_base(std::allocator_arg_t, Allocator const& a, U&& u)
126125
: alloc_(a)
127-
, ptr_(make_obj(std::forward<U>(u)))
126+
, ptr_(this->make_obj(std::forward<U>(u)))
128127
{}
129128

130129
template<class... Us>
131130
requires
132131
std::is_constructible_v<T, Us...> &&
133132
std::is_default_constructible_v<Allocator>
134133
constexpr explicit indirect_base(std::in_place_t, Us&&... us)
135-
: ptr_(make_obj(std::forward<Us>(us)...))
134+
: ptr_(this->make_obj(std::forward<Us>(us)...))
136135
{}
137136

138137
template<class... Us>
139138
requires
140139
std::is_constructible_v<T, Us...>
141140
constexpr explicit indirect_base(std::allocator_arg_t, Allocator const& a, std::in_place_t, Us&&... us)
142141
: alloc_(a)
143-
, ptr_(make_obj(std::forward<Us>(us)...))
142+
, ptr_(this->make_obj(std::forward<Us>(us)...))
144143
{}
145144

146145
template<class I, class... Us>
147146
requires
148147
std::is_constructible_v<T, std::initializer_list<I>&, Us...> &&
149148
std::is_default_constructible_v<Allocator>
150149
constexpr explicit indirect_base(std::in_place_t, std::initializer_list<I> il, Us&&... us)
151-
: ptr_(make_obj(il, std::forward<Us>(us)...))
150+
: ptr_(this->make_obj(il, std::forward<Us>(us)...))
152151
{}
153152

154153
template<class I, class... Us>
155154
requires
156155
std::is_constructible_v<T, std::initializer_list<I>&, Us...>
157156
constexpr explicit indirect_base(std::allocator_arg_t, Allocator const& a, std::in_place_t, std::initializer_list<I> il, Us&&... us)
158157
: alloc_(a)
159-
, ptr_(make_obj(il, std::forward<Us>(us)...))
158+
, ptr_(this->make_obj(il, std::forward<Us>(us)...))
160159
{}
161160

162161
constexpr ~indirect_base() noexcept
163162
{
164163
if (ptr_) [[likely]] {
165-
destroy_deallocate();
164+
this->destroy_deallocate();
166165
}
167166
}
168167

@@ -220,7 +219,7 @@ class indirect_base
220219
// other.ptr_ && (ptr_ || !ptr_)
221220
// either allocator is not equal or `this` does not contain value; create copy from `other`
222221
if (ptr_) [[likely]] {
223-
destroy_deallocate();
222+
this->destroy_deallocate();
224223
ptr_ = nullptr; // make it safer
225224
}
226225
if constexpr (pocca) {
@@ -234,7 +233,7 @@ class indirect_base
234233

235234
} else [[unlikely]] { // !other.ptr_
236235
if (ptr_) [[likely]] {
237-
destroy_deallocate();
236+
this->destroy_deallocate();
238237
ptr_ = nullptr; // make it safer
239238
}
240239
if constexpr (pocca) {
@@ -261,7 +260,7 @@ class indirect_base
261260
if (other.ptr_) [[likely]] {
262261
if constexpr (std::allocator_traits<Allocator>::is_always_equal::value) {
263262
if (ptr_) [[likely]] {
264-
destroy_deallocate();
263+
this->destroy_deallocate();
265264
}
266265
ptr_ = std::exchange(other.ptr_, nullptr);
267266
if constexpr (pocma) {
@@ -271,7 +270,7 @@ class indirect_base
271270

272271
} else if (alloc_ == other.alloc_) {
273272
if (ptr_) [[likely]] {
274-
destroy_deallocate();
273+
this->destroy_deallocate();
275274
}
276275
ptr_ = std::exchange(other.ptr_, nullptr);
277276
if constexpr (pocma) {
@@ -281,7 +280,7 @@ class indirect_base
281280

282281
} else {
283282
if (ptr_) [[likely]] {
284-
destroy_deallocate();
283+
this->destroy_deallocate();
285284
}
286285
if constexpr (pocma) {
287286
ptr_ = other.make_obj(std::move(*other));
@@ -293,7 +292,7 @@ class indirect_base
293292
}
294293
} else [[unlikely]] { // !other.ptr_
295294
if (ptr_) [[likely]] {
296-
destroy_deallocate();
295+
this->destroy_deallocate();
297296
ptr_ = nullptr;
298297
}
299298
if constexpr (pocma) {
@@ -314,7 +313,7 @@ class indirect_base
314313
**this = std::forward<U>(u);
315314

316315
} else [[unlikely]] {
317-
ptr_ = make_obj(std::forward<U>(u));
316+
ptr_ = this->make_obj(std::forward<U>(u));
318317
}
319318
return *this;
320319
}
@@ -361,7 +360,7 @@ class indirect_base
361360
template<class... Args>
362361
[[nodiscard]] constexpr T* make_obj(Args&&... args) const
363362
{
364-
detail::scoped_allocation sa(alloc_, std::in_place, std::forward<Args>(args)...);
363+
detail::scoped_allocation sa(alloc_, std::forward<Args>(args)...);
365364
return sa.release();
366365
}
367366

include/iris/requirements.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <iris/bits/specialization_of.hpp>
99

1010
#include <concepts>
11-
#include <iosfwd>
1211
#include <type_traits>
1312
#include <utility>
1413

include/iris/rvariant/detail/recursive_traits.hpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
#ifndef IRIS_ZZ_RVARIANT_DETAIL_RECURSIVE_TRAITS_HPP
1+
#ifndef IRIS_ZZ_RVARIANT_DETAIL_RECURSIVE_TRAITS_HPP
22
#define IRIS_ZZ_RVARIANT_DETAIL_RECURSIVE_TRAITS_HPP
33

44
// SPDX-License-Identifier: MIT
55

66
// IWYU pragma: private, include <iris/rvariant.hpp>
77

88
#include <iris/rvariant/detail/rvariant_fwd.hpp>
9-
#include <iris/type_traits.hpp>
109

1110
namespace iris::detail {
1211

@@ -20,10 +19,17 @@ struct select_maybe_wrapped_impl<false, I, U, U, Rest...>
2019
static constexpr std::size_t index = I;
2120
};
2221

22+
template<std::size_t I, class U, class... Rest>
23+
struct select_maybe_wrapped_impl<false, I, U, recursive_wrapper<U>, Rest...>
24+
{
25+
using type = recursive_wrapper<U>;
26+
static constexpr std::size_t index = I;
27+
};
28+
2329
template<std::size_t I, class U, class Allocator, class... Rest>
24-
struct select_maybe_wrapped_impl<false, I, U, recursive_wrapper<U, Allocator>, Rest...>
30+
struct select_maybe_wrapped_impl<false, I, U, recursive_wrapper_alloca<U, Allocator>, Rest...>
2531
{
26-
using type = recursive_wrapper<U, Allocator>;
32+
using type = recursive_wrapper_alloca<U, Allocator>;
2733
static constexpr std::size_t index = I;
2834
};
2935

@@ -37,7 +43,7 @@ struct select_maybe_wrapped : select_maybe_wrapped_impl<false, 0, U, Ts...>
3743
{
3844
// Precondition: either T or recursive_wrapper<T> occurs at least once in Ts...
3945
static_assert(sizeof...(Ts) > 0);
40-
static_assert(!is_ttp_specialization_of_v<U, recursive_wrapper>);
46+
static_assert(!detail::is_recursive_wrapper_like_v<U>);
4147
};
4248

4349
template<class U, class... Ts>

include/iris/rvariant/detail/rvariant_fwd.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#ifndef IRIS_ZZ_RVARIANT_DETAIL_RVARIANT_FWD_HPP
1+
#ifndef IRIS_ZZ_RVARIANT_DETAIL_RVARIANT_FWD_HPP
22
#define IRIS_ZZ_RVARIANT_DETAIL_RVARIANT_FWD_HPP
33

44
// SPDX-License-Identifier: MIT
@@ -20,9 +20,12 @@ namespace iris {
2020
template<class... Ts>
2121
class rvariant;
2222

23-
template<class T, class Allocator>
23+
template<class T>
2424
class recursive_wrapper;
2525

26+
template<class T, class Allocator>
27+
class recursive_wrapper_alloca;
28+
2629

2730
namespace detail {
2831

0 commit comments

Comments
 (0)