Skip to content

Commit 6698eff

Browse files
authored
Auto-update pre-commit hooks (#62)
Update versions of tools in pre-commit configs to latest version
2 parents c1a2b7d + 805f60a commit 6698eff

8 files changed

Lines changed: 126 additions & 180 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ repos:
2121

2222
# CMake linting and formatting
2323
- repo: https://github.com/BlankSpruce/gersemi-pre-commit
24-
rev: 0.27.6
24+
rev: 0.27.7
2525
hooks:
2626
- id: gersemi
2727
name: CMake linting

include/beman/expected/expected.hpp

Lines changed: 51 additions & 56 deletions
Large diffs are not rendered by default.

include/beman/expected/unexpected.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,9 @@ class unexpected<E&> {
125125
// Binds E& directly to the referenced object; deleted below when G would bind to a temporary.
126126
template <class G = E>
127127
requires(!std::is_same_v<std::remove_cvref_t<G>, unexpected> &&
128-
!std::is_same_v<std::remove_cvref_t<G>, std::in_place_t> && std::is_constructible_v<E&, G&&> &&
128+
!std::is_same_v<std::remove_cvref_t<G>, std::in_place_t> && std::is_constructible_v<E&, G &&> &&
129129
!detail::reference_constructs_from_temporary_v<E&, G>)
130-
constexpr explicit unexpected(G&& e) noexcept
131-
: ptr_(std::addressof(static_cast<E&>(std::forward<G>(e)))) {}
130+
constexpr explicit unexpected(G&& e) noexcept : ptr_(std::addressof(static_cast<E&>(std::forward<G>(e)))) {}
132131

133132
// Deleted: binding would dangle (G materializes a temporary)
134133
template <class G>
@@ -138,7 +137,7 @@ class unexpected<E&> {
138137
// Deleted catch-all: neither constructible nor a dangling case
139138
template <class G>
140139
requires(!std::is_same_v<std::remove_cvref_t<G>, unexpected> &&
141-
!std::is_same_v<std::remove_cvref_t<G>, std::in_place_t> && !std::is_constructible_v<E&, G&&> &&
140+
!std::is_same_v<std::remove_cvref_t<G>, std::in_place_t> && !std::is_constructible_v<E&, G &&> &&
142141
!detail::reference_constructs_from_temporary_v<E&, G>)
143142
constexpr unexpected(G&&) = delete;
144143

@@ -147,7 +146,7 @@ class unexpected<E&> {
147146
// reference or not. Naturally restricted to arity 1: there is no variadic overload here,
148147
// and expected only ever calls this when is_constructible_v<E&, Args...> already holds.
149148
template <class G = E>
150-
requires(std::is_constructible_v<E&, G&&> && !detail::reference_constructs_from_temporary_v<E&, G>)
149+
requires(std::is_constructible_v<E&, G &&> && !detail::reference_constructs_from_temporary_v<E&, G>)
151150
constexpr explicit unexpected(std::in_place_t, G&& e) noexcept
152151
: ptr_(std::addressof(static_cast<E&>(std::forward<G>(e)))) {}
153152

papers/wg21-latex/implementation.hpp

Lines changed: 53 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ template <class T>
1010
class optional<T&> {
1111
public:
1212
using value_type = T;
13-
using iterator =
14-
std::contiguous_iterator<T,
15-
optional>; // see [optionalref.iterators]
13+
using iterator = std::contiguous_iterator<T,
14+
optional>; // see [optionalref.iterators]
1615
public:
1716
// \ref{optionalref.ctor}, constructors
1817

@@ -21,13 +20,11 @@ class optional<T&> {
2120
constexpr optional(const optional& rhs) noexcept = default;
2221

2322
template <class Arg>
24-
requires(std::is_constructible_v<T&, Arg> &&
25-
!std::reference_constructs_from_temporary_v<T&, Arg>)
23+
requires(std::is_constructible_v<T&, Arg> && !std::reference_constructs_from_temporary_v<T&, Arg>)
2624
constexpr explicit optional(in_place_t, Arg&& arg);
2725

2826
template <class U>
29-
requires(std::is_constructible_v<T&, U> &&
30-
!(std::is_same_v<std::remove_cvref_t<U>, in_place_t>) &&
27+
requires(std::is_constructible_v<T&, U> && !(std::is_same_v<std::remove_cvref_t<U>, in_place_t>) &&
3128
!(std::is_same_v<std::remove_cvref_t<U>, optional>) &&
3229
!std::reference_constructs_from_temporary_v<T&, U>)
3330
constexpr explicit(!std::is_convertible_v<U, T&>)
@@ -36,8 +33,7 @@ class optional<T&> {
3633
}
3734

3835
template <class U>
39-
requires(std::is_constructible_v<T&, U> &&
40-
!(std::is_same_v<std::remove_cvref_t<U>, in_place_t>) &&
36+
requires(std::is_constructible_v<T&, U> && !(std::is_same_v<std::remove_cvref_t<U>, in_place_t>) &&
4137
!(std::is_same_v<std::remove_cvref_t<U>, optional>) &&
4238
std::reference_constructs_from_temporary_v<T&, U>)
4339
constexpr optional(U&& u) = delete;
@@ -47,66 +43,47 @@ class optional<T&> {
4743
// allows correct constraints by propagating the value category from the
4844
// optional to the value within the rhs.
4945
template <class U>
50-
requires(std::is_constructible_v<T&, U&> &&
51-
!std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
52-
!std::is_same_v<T&, U> &&
53-
!std::reference_constructs_from_temporary_v<T&, U&>)
54-
constexpr explicit(!std::is_convertible_v<U&, T&>) optional(
55-
optional<U>& rhs) noexcept(std::is_nothrow_constructible_v<T&, U&>);
46+
requires(std::is_constructible_v<T&, U&> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
47+
!std::is_same_v<T&, U> && !std::reference_constructs_from_temporary_v<T&, U&>)
48+
constexpr explicit(!std::is_convertible_v<U&, T&>)
49+
optional(optional<U>& rhs) noexcept(std::is_nothrow_constructible_v<T&, U&>);
5650

5751
template <class U>
58-
requires(std::is_constructible_v<T&, const U&> &&
59-
!std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
60-
!std::is_same_v<T&, U> &&
61-
!std::reference_constructs_from_temporary_v<T&, const U&>)
52+
requires(std::is_constructible_v<T&, const U&> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
53+
!std::is_same_v<T&, U> && !std::reference_constructs_from_temporary_v<T&, const U&>)
6254
constexpr explicit(!std::is_convertible_v<const U&, T&>)
63-
optional(const optional<U>& rhs) noexcept(
64-
std::is_nothrow_constructible_v<T&, const U&>);
55+
optional(const optional<U>& rhs) noexcept(std::is_nothrow_constructible_v<T&, const U&>);
6556

6657
template <class U>
67-
requires(std::is_constructible_v<T&, U> &&
68-
!std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
69-
!std::is_same_v<T&, U> &&
70-
!std::reference_constructs_from_temporary_v<T&, U>)
58+
requires(std::is_constructible_v<T&, U> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
59+
!std::is_same_v<T&, U> && !std::reference_constructs_from_temporary_v<T&, U>)
7160
constexpr explicit(!std::is_convertible_v<U, T&>)
72-
optional(optional<U>&& rhs) noexcept(
73-
noexcept(std::is_nothrow_constructible_v<T&, U>));
61+
optional(optional<U>&& rhs) noexcept(noexcept(std::is_nothrow_constructible_v<T&, U>));
7462

7563
template <class U>
76-
requires(std::is_constructible_v<T&, const U> &&
77-
!std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
78-
!std::is_same_v<T&, U> &&
79-
!std::reference_constructs_from_temporary_v<T&, const U>)
64+
requires(std::is_constructible_v<T&, const U> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
65+
!std::is_same_v<T&, U> && !std::reference_constructs_from_temporary_v<T&, const U>)
8066
constexpr explicit(!std::is_convertible_v<const U, T&>)
81-
optional(const optional<U>&& rhs) noexcept(
82-
noexcept(std::is_nothrow_constructible_v<T&, const U>));
67+
optional(const optional<U>&& rhs) noexcept(noexcept(std::is_nothrow_constructible_v<T&, const U>));
8368

8469
template <class U>
85-
requires(std::is_constructible_v<T&, U&> &&
86-
!std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
87-
!std::is_same_v<T&, U> &&
88-
std::reference_constructs_from_temporary_v<T&, U&>)
70+
requires(std::is_constructible_v<T&, U&> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
71+
!std::is_same_v<T&, U> && std::reference_constructs_from_temporary_v<T&, U&>)
8972
constexpr optional(optional<U>& rhs) = delete;
9073

9174
template <class U>
92-
requires(std::is_constructible_v<T&, const U&> &&
93-
!std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
94-
!std::is_same_v<T&, U> &&
95-
std::reference_constructs_from_temporary_v<T&, const U&>)
75+
requires(std::is_constructible_v<T&, const U&> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
76+
!std::is_same_v<T&, U> && std::reference_constructs_from_temporary_v<T&, const U&>)
9677
constexpr optional(const optional<U>& rhs) = delete;
9778

9879
template <class U>
99-
requires(std::is_constructible_v<T&, U> &&
100-
!std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
101-
!std::is_same_v<T&, U> &&
102-
std::reference_constructs_from_temporary_v<T&, U>)
80+
requires(std::is_constructible_v<T&, U> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
81+
!std::is_same_v<T&, U> && std::reference_constructs_from_temporary_v<T&, U>)
10382
constexpr optional(optional<U>&& rhs) = delete;
10483

10584
template <class U>
106-
requires(std::is_constructible_v<T&, const U> &&
107-
!std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
108-
!std::is_same_v<T&, U> &&
109-
std::reference_constructs_from_temporary_v<T&, const U>)
85+
requires(std::is_constructible_v<T&, const U> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
86+
!std::is_same_v<T&, U> && std::reference_constructs_from_temporary_v<T&, const U>)
11087
constexpr optional(const optional<U>&& rhs) = delete;
11188

11289
// \ref{optionalref.dtor}, destructor
@@ -118,10 +95,8 @@ class optional<T&> {
11895
constexpr optional& operator=(const optional& rhs) noexcept = default;
11996

12097
template <class U>
121-
requires(std::is_constructible_v<T&, U> &&
122-
!std::reference_constructs_from_temporary_v<T&, U>)
123-
constexpr T&
124-
emplace(U&& u) noexcept(std::is_nothrow_constructible_v<T&, U>);
98+
requires(std::is_constructible_v<T&, U> && !std::reference_constructs_from_temporary_v<T&, U>)
99+
constexpr T& emplace(U&& u) noexcept(std::is_nothrow_constructible_v<T&, U>);
125100

126101
// \ref{optionalref.swap}, swap
127102
constexpr void swap(optional& rhs) noexcept;
@@ -167,8 +142,7 @@ class optional<T&> {
167142
// \rSec3[optionalref.ctor]{Constructors}
168143
template <class T>
169144
template <class Arg>
170-
requires(std::is_constructible_v<T&, Arg> &&
171-
!std::reference_constructs_from_temporary_v<T&, Arg>)
145+
requires(std::is_constructible_v<T&, Arg> && !std::reference_constructs_from_temporary_v<T&, Arg>)
172146
constexpr optional<T&>::optional(in_place_t, Arg&& arg) {
173147
convert_ref_init_val(std::forward<Arg>(arg));
174148
}
@@ -187,49 +161,38 @@ constexpr optional<T&>::optional(in_place_t, Arg&& arg) {
187161

188162
template <class T>
189163
template <class U>
190-
requires(std::is_constructible_v<T&, U&> &&
191-
!std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
192-
!std::is_same_v<T&, U> &&
193-
!std::reference_constructs_from_temporary_v<T&, U&>)
194-
constexpr optional<T&>::optional(optional<U>& rhs) noexcept(
195-
std::is_nothrow_constructible_v<T&, U&>) {
164+
requires(std::is_constructible_v<T&, U&> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
165+
!std::is_same_v<T&, U> && !std::reference_constructs_from_temporary_v<T&, U&>)
166+
constexpr optional<T&>::optional(optional<U>& rhs) noexcept(std::is_nothrow_constructible_v<T&, U&>) {
196167
if (rhs.has_value()) {
197168
convert_ref_init_val(*rhs);
198169
}
199170
}
200171

201172
template <class T>
202173
template <class U>
203-
requires(std::is_constructible_v<T&, const U&> &&
204-
!std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
205-
!std::is_same_v<T&, U> &&
206-
!std::reference_constructs_from_temporary_v<T&, const U&>)
207-
constexpr optional<T&>::optional(const optional<U>& rhs) noexcept(
208-
std::is_nothrow_constructible_v<T&, const U&>) {
174+
requires(std::is_constructible_v<T&, const U&> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
175+
!std::is_same_v<T&, U> && !std::reference_constructs_from_temporary_v<T&, const U&>)
176+
constexpr optional<T&>::optional(const optional<U>& rhs) noexcept(std::is_nothrow_constructible_v<T&, const U&>) {
209177
if (rhs.has_value()) {
210178
convert_ref_init_val(*rhs);
211179
}
212180
}
213181

214182
template <class T>
215183
template <class U>
216-
requires(std::is_constructible_v<T&, U> &&
217-
!std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
218-
!std::is_same_v<T&, U> &&
219-
!std::reference_constructs_from_temporary_v<T&, U>)
220-
constexpr optional<T&>::optional(optional<U>&& rhs) noexcept(
221-
noexcept(std::is_nothrow_constructible_v<T&, U>)) {
184+
requires(std::is_constructible_v<T&, U> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
185+
!std::is_same_v<T&, U> && !std::reference_constructs_from_temporary_v<T&, U>)
186+
constexpr optional<T&>::optional(optional<U>&& rhs) noexcept(noexcept(std::is_nothrow_constructible_v<T&, U>)) {
222187
if (rhs.has_value()) {
223188
convert_ref_init_val(*std::move(rhs));
224189
}
225190
}
226191

227192
template <class T>
228193
template <class U>
229-
requires(std::is_constructible_v<T&, const U> &&
230-
!std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
231-
!std::is_same_v<T&, U> &&
232-
!std::reference_constructs_from_temporary_v<T&, const U>)
194+
requires(std::is_constructible_v<T&, const U> && !std::is_same_v<std::remove_cv_t<T>, optional<U>> &&
195+
!std::is_same_v<T&, U> && !std::reference_constructs_from_temporary_v<T&, const U>)
233196
constexpr optional<T&>::optional(const optional<U>&& rhs) noexcept(
234197
noexcept(std::is_nothrow_constructible_v<T&, const U>)) {
235198
if (rhs.has_value()) {
@@ -246,10 +209,8 @@ constexpr optional<T&>& optional<T&>::operator=(nullopt_t) noexcept {
246209

247210
template <class T>
248211
template <class U>
249-
requires(std::is_constructible_v<T&, U> &&
250-
!std::reference_constructs_from_temporary_v<T&, U>)
251-
constexpr T&
252-
optional<T&>::emplace(U&& u) noexcept(std::is_nothrow_constructible_v<T&, U>) {
212+
requires(std::is_constructible_v<T&, U> && !std::reference_constructs_from_temporary_v<T&, U>)
213+
constexpr T& optional<T&>::emplace(U&& u) noexcept(std::is_nothrow_constructible_v<T&, U>) {
253214
convert_ref_init_val(std::forward<U>(u));
254215
return *value_;
255216
}
@@ -301,12 +262,9 @@ constexpr T& optional<T&>::value() const {
301262
template <class T>
302263
template <class U>
303264
constexpr std::remove_cv_t<T> optional<T&>::value_or(U&& u) const {
304-
static_assert(std::is_constructible_v<std::remove_cv_t<T>, T&>,
305-
"T must be constructible from a T&");
306-
static_assert(std::is_convertible_v<U, std::remove_cv_t<T>>,
307-
"Must be able to convert u to T");
308-
return has_value() ? *value_
309-
: static_cast<std::remove_cv_t<T>>(std::forward<U>(u));
265+
static_assert(std::is_constructible_v<std::remove_cv_t<T>, T&>, "T must be constructible from a T&");
266+
static_assert(std::is_convertible_v<U, std::remove_cv_t<T>>, "Must be able to convert u to T");
267+
return has_value() ? *value_ : static_cast<std::remove_cv_t<T>>(std::forward<U>(u));
310268
}
311269

312270
// \rSec3[optionalref.monadic]{Monadic operations}
@@ -324,15 +282,11 @@ constexpr auto optional<T&>::and_then(F&& f) const {
324282

325283
template <class T>
326284
template <class F>
327-
constexpr optional<std::invoke_result_t<F, T&>>
328-
optional<T&>::transform(F&& f) const {
285+
constexpr optional<std::invoke_result_t<F, T&>> optional<T&>::transform(F&& f) const {
329286
using U = std::invoke_result_t<F, T&>;
330-
static_assert(!std::is_same_v<std::remove_cvref_t<U>, in_place_t>,
331-
"Result must not be in_place_t");
332-
static_assert(!std::is_same_v<std::remove_cvref_t<U>, nullopt_t>,
333-
"Result must not be nullopt_t");
334-
static_assert((std::is_object_v<U> && !std::is_array_v<U>) ||
335-
std::is_lvalue_reference_v<U>,
287+
static_assert(!std::is_same_v<std::remove_cvref_t<U>, in_place_t>, "Result must not be in_place_t");
288+
static_assert(!std::is_same_v<std::remove_cvref_t<U>, nullopt_t>, "Result must not be nullopt_t");
289+
static_assert((std::is_object_v<U> && !std::is_array_v<U>) || std::is_lvalue_reference_v<U>,
336290
"Result must be an non-array object or an lvalue reference");
337291
if (has_value()) {
338292
return optional<U>{std::invoke(std::forward<F>(f), *value_)};
@@ -345,8 +299,7 @@ template <class T>
345299
template <class F>
346300
constexpr optional<T&> optional<T&>::or_else(F&& f) const {
347301
using U = std::invoke_result_t<F>;
348-
static_assert(std::is_same_v<std::remove_cvref_t<U>, optional>,
349-
"Result must be an optional");
302+
static_assert(std::is_same_v<std::remove_cvref_t<U>, optional>, "Result must be an optional");
350303
if (has_value()) {
351304
return *value_;
352305
} else {
@@ -364,15 +317,11 @@ constexpr void optional<T&>::reset() noexcept {
364317
namespace std {
365318
template <typename T>
366319
requires requires(T a) {
367-
{
368-
std::hash<remove_const_t<T>>{}(a)
369-
} -> std::convertible_to<std::size_t>;
320+
{ std::hash<remove_const_t<T>>{}(a) } -> std::convertible_to<std::size_t>;
370321
}
371322
struct hash<beman::optional::optional<T>> {
372-
static_assert(!is_reference_v<T>,
373-
"hash is not enabled for reference types");
374-
size_t operator()(const beman::optional::optional<T>& o) const
375-
noexcept(noexcept(hash<remove_const_t<T>>{}(*o))) {
323+
static_assert(!is_reference_v<T>, "hash is not enabled for reference types");
324+
size_t operator()(const beman::optional::optional<T>& o) const noexcept(noexcept(hash<remove_const_t<T>>{}(*o))) {
376325
if (o) {
377326
return std::hash<std::remove_const_t<T>>{}(*o);
378327
} else {

tests/beman/expected/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ if(NOT BEMAN_EXPECTED_USING_LIBCXX)
7878
beman.expected.tests.expected.std
7979
PRIVATE BEMAN_EXPECTED_TEST_STD
8080
)
81-
target_compile_features(beman.expected.tests.expected.std PRIVATE cxx_std_23)
81+
target_compile_features(
82+
beman.expected.tests.expected.std
83+
PRIVATE cxx_std_23
84+
)
8285
target_include_directories(
8386
beman.expected.tests.expected.std
8487
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/tests

tests/beman/expected/expected_ref.test.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,8 +522,8 @@ TEST_CASE("expected<T&>: const transform", "[expected_ref]") {
522522

523523
TEST_CASE("expected<T&>: const transform on error - propagates", "[expected_ref]") {
524524
const expected<int&, int> e(unexpect, 5);
525-
bool called = false;
526-
auto r = e.transform([&](int&) {
525+
bool called = false;
526+
auto r = e.transform([&](int&) {
527527
called = true;
528528
return 0;
529529
});

0 commit comments

Comments
 (0)