Skip to content

Commit b6141b6

Browse files
committed
fix(*): fixing compile erros
1 parent b9773cb commit b6141b6

38 files changed

+531
-173
lines changed

.clang-format

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ EmptyLineBeforeAccessModifier: Always
2929
FixNamespaceComments: false
3030
IncludeBlocks: Regroup
3131
IncludeCategories:
32-
- Regex: '(../)*compilation_config_in.h'
33-
SortPriority: 99
34-
Priority: 99
35-
- Regex: '".+"'
36-
SortPriority: 0
37-
Priority: 0
38-
- Regex: '<.+/.+>'
39-
SortPriority: 1
40-
Priority: 1
41-
- Regex: '<.+>'
42-
SortPriority: 2
43-
Priority: 2
32+
- Regex: "(../)*compilation_config_in.h"
33+
SortPriority: 99
34+
Priority: 99
35+
- Regex: '".+"'
36+
SortPriority: 0
37+
Priority: 0
38+
- Regex: "<.+/.+>"
39+
SortPriority: 1
40+
Priority: 1
41+
- Regex: "<.+>"
42+
SortPriority: 2
43+
Priority: 2
4444
IndentGotoLabels: false
4545
IndentPPDirectives: BeforeHash
4646
IndentWidth: 4
@@ -49,7 +49,17 @@ KeepEmptyLinesAtTheStartOfBlocks: false
4949
MaxEmptyLinesToKeep: 2
5050
NamespaceIndentation: All
5151
PackConstructorInitializers: NextLine
52-
PenaltyBreakFirstLessLess: 3
52+
PenaltyBreakAssignment: 20
53+
PenaltyBreakBeforeFirstCallParameter: 10
54+
PenaltyBreakComment: 0
55+
PenaltyBreakFirstLessLess: 0
56+
PenaltyBreakOpenParenthesis: 10
57+
PenaltyBreakScopeResolution: 30
58+
PenaltyBreakString: 100
59+
PenaltyBreakTemplateDeclaration: 100
60+
PenaltyExcessCharacter: 1000
61+
PenaltyIndentedWhitespace: 0
62+
PenaltyReturnTypeOnItsOwnLine: 50
5363
PointerAlignment: Left
5464
QualifierAlignment: Left
5565
SeparateDefinitionBlocks: Always

include/stdsharp/cstdint/cstdint.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include <limits>
77
#include <stdexcept>
88

9-
109
namespace stdsharp
1110
{
1211
inline constexpr std::size_t char_bit = CHAR_BIT;

include/stdsharp/default_operator.h

Lines changed: 106 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace stdsharp::default_operator
77
struct increase
88
{
99
template<std::copy_constructible T>
10-
[[nodiscard]] constexpr auto operator++(this T& t, int)
10+
[[nodiscard]] friend constexpr auto operator++(T& t, int)
1111
noexcept(nothrow_copy_constructible<T> && noexcept(++t))
1212
requires requires { ++t; }
1313
{
@@ -17,7 +17,7 @@ namespace stdsharp::default_operator
1717
}
1818

1919
template<std::copy_constructible T>
20-
[[nodiscard]] constexpr auto operator--(this T& t, int)
20+
[[nodiscard]] friend constexpr auto operator--(T& t, int)
2121
noexcept(nothrow_copy_constructible<T> && noexcept(--t))
2222
requires requires { --t; }
2323
{
@@ -27,7 +27,7 @@ namespace stdsharp::default_operator
2727
}
2828
};
2929

30-
struct arithmetic
30+
struct arithmetic : increase
3131
{
3232
constexpr auto& operator++(this auto& t) noexcept(noexcept(t += 1))
3333
requires requires { t += 1; }
@@ -64,24 +64,73 @@ namespace stdsharp::default_operator
6464
STDSHARP_ARITH_OP(<<)
6565
STDSHARP_ARITH_OP(>>)
6666

67-
[[nodiscard]] constexpr auto operator-(this const auto& t)
68-
noexcept(noexcept(0 - t)) -> decltype(0 - t)
69-
{
70-
return 0 - t;
71-
};
67+
#undef STDSHARP_ARITH_OP
68+
};
69+
70+
struct inverse_arithmetic : arithmetic
71+
{
72+
#define STDSHARP_ARITH_OP(op) \
73+
template<typename U> \
74+
[[nodiscard]] friend constexpr decltype(auto) operator op(U&& u, auto&& t) /**/ \
75+
noexcept(noexcept(cpp_forward(t) op cpp_forward(u))) \
76+
requires requires { \
77+
requires !std::is_base_of_v<inverse_arithmetic, std::remove_reference_t<U>>; \
78+
cpp_forward(t) op cpp_forward(u); \
79+
} \
80+
{ \
81+
return cpp_forward(t) op cpp_forward(u); \
82+
}
83+
84+
STDSHARP_ARITH_OP(+)
85+
STDSHARP_ARITH_OP(-)
86+
STDSHARP_ARITH_OP(*)
87+
STDSHARP_ARITH_OP(/)
88+
STDSHARP_ARITH_OP(%)
89+
STDSHARP_ARITH_OP(&)
90+
STDSHARP_ARITH_OP(|)
91+
STDSHARP_ARITH_OP(^)
92+
STDSHARP_ARITH_OP(<<)
93+
STDSHARP_ARITH_OP(>>)
94+
95+
#undef STDSHARP_ARITH_OP
96+
97+
#define STDSHARP_ARITH_OP(op) \
98+
[[nodiscard]] friend constexpr auto operator op(const auto& t) noexcept(noexcept(0 op t)) \
99+
->decltype(0 op t) \
100+
{ \
101+
return 0 op t; \
102+
}; \
103+
\
104+
template<std::default_initializable T> \
105+
[[nodiscard]] friend constexpr decltype(auto) operator op(const T& t \
106+
) noexcept(noexcept(T {} op t)) \
107+
requires requires { \
108+
requires !requires { 0 op t; }; \
109+
T {} \
110+
op t; \
111+
} \
112+
{ \
113+
return T {} \
114+
op t; \
115+
};
116+
117+
STDSHARP_ARITH_OP(+)
118+
STDSHARP_ARITH_OP(-)
119+
120+
#undef STDSHARP_ARITH_OP
72121
};
73122

74123
struct arrow
75124
{
76-
[[nodiscard]] constexpr decltype(auto) operator->(this dereferenceable auto&& t)
77-
noexcept(noexcept(*cpp_forward(t)))
125+
[[nodiscard]] constexpr auto* operator->(this dereferenceable auto&& t)
126+
noexcept(noexcept(std::addressof(*cpp_forward(t))))
78127
{
79-
return *cpp_forward(t);
128+
return std::addressof(*cpp_forward(t));
80129
}
81130

82-
[[nodiscard]] constexpr decltype(auto
83-
) operator->*(this dereferenceable auto&& t, auto&& ptr)
131+
[[nodiscard]] constexpr auto operator->*(this dereferenceable auto&& t, auto&& ptr)
84132
noexcept(noexcept((*cpp_forward(t)).*cpp_forward(ptr)))
133+
requires requires { (*cpp_forward(t)).*cpp_forward(ptr); }
85134
{
86135
return (*cpp_forward(t)).*cpp_forward(ptr);
87136
}
@@ -90,13 +139,52 @@ namespace stdsharp::default_operator
90139
struct subscript
91140
{
92141
#if __cpp_multidimensional_subscript >= 202110L
93-
[[nodiscard]] constexpr decltype(auto
94-
) operator[](this auto&& t, auto&& first_arg, auto&&... args) noexcept( //
95-
noexcept(cpp_forward(t)[cpp_forward(first_arg)][cpp_forward(args)...])
142+
[[nodiscard]] constexpr decltype(auto) operator[]( //
143+
this auto&& t,
144+
auto&& first_arg,
145+
auto&& second_arg
146+
) noexcept( //
147+
noexcept( //
148+
cpp_forward(t) //
149+
[cpp_forward(first_arg)] //
150+
[cpp_forward(second_arg)]
151+
)
152+
)
153+
requires requires {
154+
cpp_forward(t) //
155+
[cpp_forward(first_arg)] //
156+
[cpp_forward(second_arg)];
157+
}
158+
{
159+
return cpp_forward(t) //
160+
[cpp_forward(first_arg)] //
161+
[cpp_forward(second_arg)];
162+
}
163+
164+
[[nodiscard]] constexpr decltype(auto) operator[]( //
165+
this auto&& t,
166+
auto&& first_arg,
167+
auto&& second_arg,
168+
auto&&... args
169+
) noexcept( //
170+
noexcept( //
171+
cpp_forward(t) //
172+
[cpp_forward(first_arg)] //
173+
[cpp_forward(second_arg)] //
174+
[cpp_forward(args)...]
175+
)
96176
)
97-
requires requires { cpp_forward(t)[cpp_forward(first_arg)][cpp_forward(args)...]; }
177+
requires requires {
178+
cpp_forward(t) //
179+
[cpp_forward(first_arg)] //
180+
[cpp_forward(second_arg)] //
181+
[cpp_forward(args)...];
182+
}
98183
{
99-
return cpp_forward(t)[cpp_forward(first_arg)][cpp_forward(args)...];
184+
return cpp_forward(t) //
185+
[cpp_forward(first_arg)] //
186+
[cpp_forward(second_arg)] //
187+
[cpp_forward(args)...];
100188
}
101189
#endif
102190
};

include/stdsharp/format/format.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <unicode-db.hpp>
1111
#include <variant>
1212

13-
1413
namespace stdsharp
1514
{
1615
namespace details

include/stdsharp/functional/forward_bind.h

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ namespace stdsharp::details
4646
func_t func;
4747
args_t args;
4848

49+
template<typename F, typename... Args>
50+
requires std::constructible_from<func_t, F> &&
51+
std::constructible_from<args_t, Args...>
52+
constexpr binder(F&& f, Args&&... args) noexcept(
53+
nothrow_constructible_from<func_t, F> &&
54+
nothrow_constructible_from<args_t, Args...> //
55+
):
56+
func(cpp_forward(f)), args(forward(cpp_forward(args))...)
57+
{
58+
}
59+
4960
template<
5061
typename Self,
5162
typename Seq = args_t::index_sequence,
@@ -65,14 +76,16 @@ namespace stdsharp::details
6576
template<
6677
typename Func,
6778
typename... BindArgs,
68-
typename Binder = BinderImpl<Func, BindArgs...>>
79+
typename Binder = BinderImpl<Func, BindArgs...>,
80+
typename func_t = Binder::func_t,
81+
typename args_t = Binder::args_t>
82+
requires std::constructible_from<Binder, func_t, args_t>
6983
constexpr auto operator()(Func&& func, BindArgs&&... bind_args) const noexcept(
7084
nothrow_constructible_from<Binder, Func, forward_t<BindArgs>...> &&
71-
noexcept(Binder{cpp_move(func), {forward(cpp_forward(bind_args))...}})
85+
nothrow_constructible_from<Binder, func_t, args_t> //
7286
)
73-
requires requires { Binder{cpp_move(func), {forward(cpp_forward(bind_args))...}}; }
7487
{
75-
return Binder{cpp_move(func), {forward(cpp_forward(bind_args))...}};
88+
return Binder{func_t{cpp_move(func)}, args_t{forward(cpp_forward(bind_args))...}};
7689
}
7790
};
7891

@@ -85,6 +98,7 @@ namespace stdsharp::details
8598
private:
8699
using m_base = details::forward_bind::
87100
binder<forward_bind_front_binder<Func, BindArgs...>, Func, BindArgs...>;
101+
88102
friend m_base;
89103

90104
template<
@@ -105,6 +119,9 @@ namespace stdsharp::details
105119
cpp_forward(args)...
106120
);
107121
}
122+
123+
public:
124+
using m_base::m_base;
108125
};
109126

110127
template<typename Func, typename... BindArgs>
@@ -116,6 +133,7 @@ namespace stdsharp::details
116133
private:
117134
using m_base = details::forward_bind::
118135
binder<forward_bind_back_binder<Func, BindArgs...>, Func, BindArgs...>;
136+
119137
friend m_base;
120138

121139
template<
@@ -136,6 +154,9 @@ namespace stdsharp::details
136154
get_forwarded<BindArgs>(cpp_forward(self).m_base::args.template get<I>())...
137155
);
138156
}
157+
158+
public:
159+
using m_base::m_base;
139160
};
140161
}
141162

include/stdsharp/functional/invocables.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ namespace stdsharp::details
3333
struct STDSHARP_EBO invocables<std::index_sequence<I...>, Func...> :
3434
indexed_invocable<I, Func>...
3535
{
36+
using indexed_invocable<I, Func>::operator()...;
37+
3638
static constexpr auto size() noexcept { return sizeof...(Func); }
3739

3840
template<std::size_t J>
@@ -63,6 +65,25 @@ namespace stdsharp
6365
template<typename... Func>
6466
struct invocables : details::invocables<std::index_sequence_for<Func...>, Func...>
6567
{
68+
private:
69+
using m_base = details::invocables<std::index_sequence_for<Func...>, Func...>;
70+
71+
public:
72+
invocables() = default;
73+
74+
constexpr invocables(Func&&... func)
75+
noexcept(nothrow_list_initializable_from<m_base, Func...>)
76+
requires list_initializable_from<m_base, Func...>
77+
: m_base{cpp_move(func)...}
78+
{
79+
}
80+
81+
template<typename... T>
82+
requires list_initializable_from<m_base, T...>
83+
constexpr invocables(T&&... t) noexcept(nothrow_list_initializable_from<m_base, T...>):
84+
m_base{cpp_forward(t)...}
85+
{
86+
}
6687
};
6788

6889
template<typename... T>

0 commit comments

Comments
 (0)