Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
b135f1c0
Commit
b135f1c0
authored
Jun 09, 2022
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor handling of argument types
parent
f61a1e81
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
20 deletions
+10
-20
include/fmt/compile.h
include/fmt/compile.h
+2
-2
include/fmt/core.h
include/fmt/core.h
+6
-16
test/core-test.cc
test/core-test.cc
+2
-2
No files found.
include/fmt/compile.h
View file @
b135f1c0
...
...
@@ -337,8 +337,8 @@ template <typename T, typename Char>
constexpr
parse_specs_result
<
T
,
Char
>
parse_specs
(
basic_string_view
<
Char
>
str
,
size_t
pos
,
int
next_arg_id
)
{
str
.
remove_prefix
(
pos
);
auto
ctx
=
compile_parse_context
<
Char
>
(
str
,
format_arg_types
<
10
>
(),
{},
next_arg_id
);
auto
ctx
=
compile_parse_context
<
Char
>
(
str
,
max_value
<
int
>
(),
nullptr
,
{},
next_arg_id
);
auto
f
=
formatter
<
T
,
Char
>
();
auto
end
=
f
.
parse
(
ctx
);
return
{
f
,
pos
+
fmt
::
detail
::
to_unsigned
(
end
-
str
.
data
())
+
1
,
...
...
include/fmt/core.h
View file @
b135f1c0
...
...
@@ -597,15 +597,6 @@ constexpr bool is_arithmetic_type(type t) {
return
t
>
type
::
none_type
&&
t
<=
type
::
last_numeric_type
;
}
template
<
size_t
NUM_ARGS
>
struct
format_arg_types
{
type
types
[
NUM_ARGS
>
0
?
NUM_ARGS
:
1
];
};
template
<
typename
...
T
>
constexpr
format_arg_types
<
sizeof
...(
T
)
>
make_format_arg_types
()
{
return
{
type_constant
<
T
,
char
>::
value
...};
}
FMT_NORETURN
FMT_API
void
throw_format_error
(
const
char
*
message
);
struct
error_handler
{
...
...
@@ -713,13 +704,10 @@ class compile_parse_context
using
base
=
basic_format_parse_context
<
Char
,
ErrorHandler
>
;
public:
template
<
size_t
NUM_ARGS
>
explicit
FMT_CONSTEXPR
compile_parse_context
(
basic_string_view
<
Char
>
format_str
,
const
format_arg_types
<
NUM_ARGS
>&
t
,
basic_string_view
<
Char
>
format_str
,
int
num_args
,
const
type
*
types
,
ErrorHandler
eh
=
{},
int
next_arg_id
=
0
)
:
base
(
format_str
,
eh
,
next_arg_id
),
num_args_
(
NUM_ARGS
),
types_
(
t
.
types
)
{}
:
base
(
format_str
,
eh
,
next_arg_id
),
num_args_
(
num_args
),
types_
(
types
)
{}
constexpr
int
num_args
()
const
{
return
num_args_
;
}
...
...
@@ -2900,12 +2888,14 @@ class format_string_checker {
parse_context_type
context_
;
parse_func
parse_funcs_
[
num_args
>
0
?
num_args
:
1
];
type
types_
[
num_args
>
0
?
num_args
:
1
];
public:
explicit
FMT_CONSTEXPR
format_string_checker
(
basic_string_view
<
Char
>
format_str
,
ErrorHandler
eh
)
:
context_
(
format_str
,
make_format_arg_types
<
Args
...
>
(),
eh
),
parse_funcs_
{
&
parse_format_specs
<
Args
,
parse_context_type
>
...}
{}
:
context_
(
format_str
,
num_args
,
types_
,
eh
),
parse_funcs_
{
&
parse_format_specs
<
Args
,
parse_context_type
>
...},
types_
{
type_constant
<
Args
,
char
>::
value
...}
{}
FMT_CONSTEXPR
void
on_text
(
const
Char
*
,
const
Char
*
)
{}
...
...
test/core-test.cc
View file @
b135f1c0
...
...
@@ -385,11 +385,11 @@ VISIT_TYPE(unsigned long, unsigned long long);
template
<
typename
T
>
class
numeric_arg_test
:
public
testing
::
Test
{};
using
types
=
using
t
est_t
ypes
=
testing
::
Types
<
bool
,
signed
char
,
unsigned
char
,
short
,
unsigned
short
,
int
,
unsigned
,
long
,
unsigned
long
,
long
long
,
unsigned
long
long
,
float
,
double
,
long
double
>
;
TYPED_TEST_SUITE
(
numeric_arg_test
,
types
);
TYPED_TEST_SUITE
(
numeric_arg_test
,
t
est_t
ypes
);
template
<
typename
T
,
fmt
::
enable_if_t
<
std
::
is_integral
<
T
>
::
value
,
int
>
=
0
>
T
test_value
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment