Skip to content

Commit 6fb40ea

Browse files
committed
sync
1 parent fa8ed77 commit 6fb40ea

36 files changed

Lines changed: 522 additions & 850 deletions

include/stdsharp/algorithm/algorithm.h

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#pragma once
2-
32
#include "../compare/compare.h"
43
#include "../functional/invoke.h"
54
#include "../functional/operations.h"
@@ -14,7 +13,7 @@ namespace stdsharp
1413
{
1514
template<typename T, typename U, std::predicate<U, T> Comp>
1615
requires std::assignable_from<T&, U>
17-
constexpr T& operator()(T& left, U&& right, Comp comp = {}) const
16+
static constexpr T& operator()(T& left, U&& right, Comp comp = {}) //
1817
noexcept(nothrow_predicate<Comp, U, T> && nothrow_assignable_from<T&, U>)
1918
{
2019
if(invoke(cpp_move(comp), right, left)) left = cpp_forward(right);
@@ -26,7 +25,7 @@ namespace stdsharp
2625
{
2726
template<typename T, typename U>
2827
requires std::invocable<set_if_fn, T&, U, std::ranges::greater>
29-
constexpr T& operator()(T& left, U&& right) const
28+
static constexpr T& operator()(T& left, U&& right) //
3029
noexcept(nothrow_invocable<set_if_fn, T&, U, std::ranges::greater>)
3130
{
3231
return set_if(left, cpp_forward(right), greater_v);
@@ -37,7 +36,7 @@ namespace stdsharp
3736
{
3837
template<typename T, typename U>
3938
requires std::invocable<set_if_fn, T&, U, std::ranges::less>
40-
constexpr T& operator()(T& left, U&& right) const
39+
static constexpr T& operator()(T& left, U&& right) //
4140
noexcept(nothrow_invocable<set_if_fn, T&, U, std::ranges::less>)
4241
{
4342
return set_if(left, cpp_forward(right), less_v);
@@ -46,17 +45,19 @@ namespace stdsharp
4645

4746
inline constexpr struct is_between_fn
4847
{
49-
template< //
48+
template<
5049
typename T,
5150
typename Proj = std::identity,
52-
std::indirect_strict_weak_order<std::projected<const T*, Proj>> Compare = std::ranges::
53-
less>
54-
[[nodiscard]] constexpr auto operator()(const T& t,
51+
std::indirect_strict_weak_order<std::projected<const T*, Proj>> Compare = //
52+
std::ranges::less>
53+
[[nodiscard]] static constexpr auto operator()(
54+
const T& t,
5555
decltype(t) min,
5656
decltype(t) max,
5757
Compare cmp = {},
58-
Proj proj = {}) const noexcept( //
59-
nothrow_predicate< //
58+
Proj proj = {}
59+
) noexcept( //
60+
nothrow_predicate<
6061
Compare,
6162
std::projected<const T*, Proj>,
6263
std::projected<const T*, Proj>> //
@@ -65,9 +66,7 @@ namespace stdsharp
6566
const auto& proj_max = invoke(proj, max);
6667
const auto& proj_min = invoke(proj, min);
6768
const auto& proj_t = invoke(proj, t);
68-
6969
Expects(!invoke(cmp, proj_max, proj_min));
70-
7170
return !invoke(cmp, proj_t, proj_min) && !invoke(cmp, proj_max, proj_t);
7271
}
7372
} is_between{};
@@ -96,7 +95,13 @@ namespace stdsharp
9695
std::sentinel_for<I2> S2,
9796
typename Cmp = std::compare_three_way>
9897
requires ordering_predicate<Cmp&, std::iter_reference_t<I1>, std::iter_reference_t<I2>>
99-
constexpr auto operator()(I1 i1, const S1 s1, I2 i2, const S2 s2, Cmp cmp = {}) const
98+
[[nodiscard]] static constexpr auto operator()(
99+
I1 i1,
100+
const S1 s1,
101+
I2 i2,
102+
const S2 s2,
103+
Cmp cmp = {}
104+
)
100105
{
101106
auto pre = ordering::equivalent;
102107

@@ -128,13 +133,15 @@ namespace stdsharp
128133
Cmp&,
129134
std::ranges::range_reference_t<R1>,
130135
std::ranges::range_reference_t<R2>>
131-
constexpr auto operator()(R1&& r1, R2&& r2, Cmp cmp = {}) const
136+
[[nodiscard]] static constexpr auto operator()(R1&& r1, R2&& r2, Cmp cmp = {}) noexcept
132137
{
133-
return (*this)(std::ranges::begin(r1),
138+
return strict_compare_fn::operator()(
139+
std::ranges::begin(r1),
134140
std::ranges::end(r1),
135141
std::ranges::begin(r2),
136142
std::ranges::end(r2),
137-
cmp);
143+
cmp
144+
);
138145
}
139146
} strict_compare{};
140147

@@ -145,11 +152,13 @@ namespace stdsharp
145152
{
146153
template<std::input_iterator In, std::weakly_incrementable Out>
147154
requires std::indirectly_movable<In, Out>
148-
constexpr move_n_result<In, Out>
149-
operator()(In in, const std::iter_difference_t<In> n, Out out) const
155+
static constexpr move_n_result<In, Out> operator()(
156+
In in,
157+
const std::iter_difference_t<In> n,
158+
Out out //
159+
)
150160
{
151161
auto&& r = std::ranges::copy_n(std::move_iterator{cpp_move(in)}, n, cpp_move(out));
152-
153162
return {cpp_move(r).in.base(), cpp_move(r).out};
154163
}
155164
} move_n{};

include/stdsharp/array/array.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#pragma once
2-
32
#include "../macros.h"
4-
#include "../namespace_alias.h"
53

64
#include <algorithm>
75
#include <array>
@@ -13,17 +11,15 @@ namespace stdsharp
1311
struct range_to_array_fn
1412
{
1513
template<typename Rng, typename Proj = std::identity>
16-
constexpr auto operator()(Rng&& rng, Proj proj = {}) const
14+
[[nodiscard]] static constexpr auto operator()(Rng&& rng, Proj proj = {})
1715
{
1816
using value_type = std::projected<std::ranges::iterator_t<Rng>, Proj>::value_type;
1917

2018
std::array<value_type, N> arr{};
21-
2219
std::ranges::copy(
2320
cpp_forward(rng) | std::views::transform(proj) | std::views::take(N),
2421
arr.begin()
2522
);
26-
2723
return arr;
2824
}
2925
};

include/stdsharp/bitset/bitset.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#pragma once
2-
32
#include "../cassert/cassert.h"
43
#include "../cstdint/cstdint.h"
54
#include "../iterator/basic_iterator.h"

include/stdsharp/cassert/cassert.h

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#pragma once
2-
32
#include "../concepts/object.h"
43
#include "../functional/invoke.h"
54

@@ -17,26 +16,25 @@ namespace stdsharp
1716
#endif
1817
;
1918

20-
inline constexpr auto assert_with = []<typename... Args>( //
21-
std::predicate<Args...> auto&& fn,
22-
Args&&... args
23-
) noexcept
19+
inline constexpr auto assert_with = //
20+
[]<typename... Args>(std::predicate<Args...> auto&& fn, Args&&... args) static noexcept
2421
{
2522
Expects(invoke(fn, cpp_forward(args)...)); //
2623
};
2724

28-
inline constexpr auto assert_equal = []<typename T, typename U>(T&& t, U&& u) noexcept
25+
inline constexpr auto assert_equal = []<typename T, typename U>(T&& t, U&& u) static noexcept
2926
requires std::invocable<decltype(assert_with), std::ranges::equal_to, T, U>
3027
{
3128
assert_with(std::ranges::equal_to{}, cpp_forward(t), cpp_forward(u)); //
3229
};
3330

34-
inline constexpr auto assert_not_equal = []<typename T, typename U>(T&& t, U&& u) noexcept
31+
inline constexpr auto assert_not_equal = //
32+
[]<typename T, typename U>(T&& t, U&& u) static noexcept
3533
requires std::invocable<decltype(assert_with), std::ranges::not_equal_to, T, U>
3634
{
3735
assert_with(std::ranges::not_equal_to{}, cpp_forward(t), cpp_forward(u)); //
3836
};
3937

4038
inline constexpr auto assert_not_null = //
41-
[](const nullable_pointer auto& ptr) noexcept { assert_not_equal(ptr, nullptr); };
39+
[](const nullable_pointer auto& ptr) static noexcept { assert_not_equal(ptr, nullptr); };
4240
}

include/stdsharp/cmath/cmath.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
#pragma once
2-
3-
#include "../namespace_alias.h"
4-
52
#include <cmath> // IWYU pragma: export
63
#include <concepts>
74

85
namespace stdsharp
96
{
10-
constexpr auto ceil(const std::integral auto x, decltype(x) y) noexcept
7+
[[nodiscard]] constexpr auto ceil(const std::integral auto x, decltype(x) y) noexcept
118
{
129
return (x + y - 1) / y;
1310
}

include/stdsharp/compare/compare.h

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
#pragma once
2-
3-
#include "../concepts/concepts.h"
4-
5-
#include <compare>
6-
7-
namespace stdsharp
8-
{
9-
template<typename Cat>
10-
concept ordering_like =
11-
same_as_any<Cat, std::partial_ordering, std::weak_ordering, std::strong_ordering>;
12-
13-
constexpr bool is_ud(const std::partial_ordering c) noexcept
14-
{
15-
return c == std::partial_ordering::unordered;
16-
}
17-
18-
constexpr bool conform_to(const std::partial_ordering l, decltype(l) r) noexcept
19-
{
20-
return is_eq(l) || l == r;
21-
}
22-
23-
template<typename Fn, typename T, typename U, typename Cat = std::partial_ordering>
24-
concept ordering_predicate = ordering_like<Cat> && regular_invocable_r<Fn, Cat, T, U>;
25-
26-
template<typename Fn, typename T, typename U, typename Cat = std::partial_ordering>
27-
concept nothrow_ordering_predicate = ordering_predicate<Fn, T, U, Cat> &&
28-
nothrow_invocable_r<Fn, Cat, T, U>;
29-
}
1+
#pragma once
2+
#include "../concepts/concepts.h"
3+
4+
#include <compare>
5+
6+
namespace stdsharp
7+
{
8+
template<typename Cat>
9+
concept ordering_like =
10+
same_as_any<Cat, std::partial_ordering, std::weak_ordering, std::strong_ordering>;
11+
12+
[[nodiscard]] constexpr bool is_ud(const std::partial_ordering c) noexcept
13+
{
14+
return c == std::partial_ordering::unordered;
15+
}
16+
17+
[[nodiscard]] constexpr bool conform_to(const std::partial_ordering l, decltype(l) r) noexcept
18+
{
19+
return is_eq(l) || l == r;
20+
}
21+
22+
template<typename Fn, typename T, typename U, typename Cat = std::partial_ordering>
23+
concept ordering_predicate = ordering_like<Cat> && regular_invocable_r<Fn, Cat, T, U>;
24+
25+
template<typename Fn, typename T, typename U, typename Cat = std::partial_ordering>
26+
concept nothrow_ordering_predicate = ordering_predicate<Fn, T, U, Cat> &&
27+
nothrow_invocable_r<Fn, Cat, T, U>;
28+
}

include/stdsharp/compilation_config_in.h

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,15 @@
1-
#if defined(__GNUG__) || defined(_MSC_VER)
2-
#pragma push_macro("STDSHARP_ALWAYS_INLINE")
3-
#pragma push_macro("STDSHARP_NO_UNIQUE_ADDRESS")
4-
#pragma push_macro("STDSHARP_INTRINSIC")
5-
#pragma push_macro("STDSHARP_EBO")
6-
#endif
7-
8-
#if defined(__GNUG__) && __has_cpp_attribute(gnu::always_inline)
1+
#if defined(__GNUG__)
92
#define STDSHARP_ALWAYS_INLINE [[gnu::always_inline]]
10-
#elif defined(_MSC_VER) && __has_cpp_attribute(msvc::forceinline)
3+
#elif defined(_MSC_VER)
114
#define STDSHARP_ALWAYS_INLINE [[msvc::forceinline]]
125
#else
136
#define STDSHARP_ALWAYS_INLINE inline
147
#endif
158

16-
#if defined(_MSC_VER) && __has_cpp_attribute(msvc::no_unique_address) && \
17-
__has_cpp_attribute(msvc::intrinsic)
18-
#define STDSHARP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
19-
#define STDSHARP_INTRINSIC [[msvc::intrinsic]] [[nodiscard]]
9+
#if defined(_MSC_VER)
10+
#define STDSHARP_INTRINSIC [[msvc::intrinsic]] [[nodiscard]] static
2011
#else
21-
#define STDSHARP_NO_UNIQUE_ADDRESS [[no_unique_address]]
22-
#define STDSHARP_INTRINSIC [[nodiscard]] STDSHARP_ALWAYS_INLINE
12+
#define STDSHARP_INTRINSIC [[nodiscard]] STDSHARP_ALWAYS_INLINE static
2313
#endif
2414

2515
#if defined(_MSC_VER) || (defined(_WIN32) && defined(__clang__))
Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#if defined(__GNUG__) || defined(_MSC_VER)
2-
#pragma pop_macro("STDSHARP_ALWAYS_INLINE")
3-
#pragma pop_macro("STDSHARP_NO_UNIQUE_ADDRESS")
4-
#pragma pop_macro("STDSHARP_INTRINSIC")
5-
#pragma pop_macro("STDSHARP_EBO")
6-
#else
7-
#undef STDSHARP_NO_UNIQUE_ADDRESS
8-
#undef STDSHARP_INTRINSIC
9-
#undef STDSHARP_ALWAYS_INLINE
10-
#undef STDSHARP_EBO
11-
#endif
1+
#undef STDSHARP_INTRINSIC
2+
#undef STDSHARP_ALWAYS_INLINE
3+
#undef STDSHARP_EBO
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#pragma once
2-
32
#include "object.h" // IWYU pragma: export
43
#include "type.h" // IWYU pragma: export

include/stdsharp/concepts/object.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#pragma once
2-
32
#include "../functional/invoke_r.h"
43
#include "type.h"
54

0 commit comments

Comments
 (0)