Skip to content

Commit 4f4e527

Browse files
refactor: Simplify numeric proxy structure by consolidating integer and floating point handling
Signed-off-by: FrozenlemonTee <1115306170@qq.com>
1 parent 988227e commit 4f4e527

1 file changed

Lines changed: 17 additions & 34 deletions

File tree

src/conversion/underlying.cppm

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -29,47 +29,30 @@ concept builtin_numeric_proxy_candidate =
2929
std::same_as<common_rep_t<Rep, Candidate>, std::remove_cv_t<Candidate>> &&
3030
statically_castable<Candidate, Rep>;
3131

32-
template <typename Rep>
33-
struct integer_builtin_proxy {
34-
using type = std::conditional_t<
35-
builtin_numeric_proxy_candidate<Rep, short>, short,
36-
std::conditional_t<
37-
builtin_numeric_proxy_candidate<Rep, unsigned short>, unsigned short,
38-
std::conditional_t<
39-
builtin_numeric_proxy_candidate<Rep, int>, int,
40-
std::conditional_t<
41-
builtin_numeric_proxy_candidate<Rep, unsigned int>,
42-
unsigned int,
43-
std::conditional_t<
44-
builtin_numeric_proxy_candidate<Rep, long>, long,
45-
std::conditional_t<
46-
builtin_numeric_proxy_candidate<Rep, unsigned long>,
47-
unsigned long,
48-
std::conditional_t<
49-
builtin_numeric_proxy_candidate<Rep, long long>,
50-
long long,
51-
std::conditional_t<
52-
builtin_numeric_proxy_candidate<
53-
Rep, unsigned long long>,
54-
unsigned long long, void>>>>>>>>;
55-
};
32+
template <typename Rep, typename... Candidates>
33+
struct builtin_numeric_proxy;
5634

5735
template <typename Rep>
58-
using integer_builtin_proxy_t = integer_builtin_proxy<Rep>::type;
36+
struct builtin_numeric_proxy<Rep> {
37+
using type = void;
38+
};
5939

60-
template <typename Rep>
61-
struct floating_builtin_proxy {
40+
template <typename Rep, typename Candidate, typename... Candidates>
41+
struct builtin_numeric_proxy<Rep, Candidate, Candidates...> {
6242
using type = std::conditional_t<
63-
builtin_numeric_proxy_candidate<Rep, float>, float,
64-
std::conditional_t<
65-
builtin_numeric_proxy_candidate<Rep, double>, double,
66-
std::conditional_t<
67-
builtin_numeric_proxy_candidate<Rep, long double>, long double,
68-
void>>>;
43+
builtin_numeric_proxy_candidate<Rep, Candidate>, Candidate,
44+
typename builtin_numeric_proxy<Rep, Candidates...>::type>;
6945
};
7046

7147
template <typename Rep>
72-
using floating_builtin_proxy_t = floating_builtin_proxy<Rep>::type;
48+
using integer_builtin_proxy_t =
49+
builtin_numeric_proxy<Rep, short, unsigned short, int,
50+
unsigned int, long, unsigned long,
51+
long long, unsigned long long>::type;
52+
53+
template <typename Rep>
54+
using floating_builtin_proxy_t =
55+
builtin_numeric_proxy<Rep, float, double, long double>::type;
7356

7457
template <std_numeric DestRep, std_numeric SrcRep>
7558
constexpr auto numeric_risk(SrcRep value)

0 commit comments

Comments
 (0)