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
b9815cf0
Commit
b9815cf0
authored
Aug 25, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify part_counter
parent
fe00cddd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
12 deletions
+6
-12
include/fmt/compile.h
include/fmt/compile.h
+6
-12
No files found.
include/fmt/compile.h
View file @
b9815cf0
...
...
@@ -261,16 +261,15 @@ class prepared_format {
};
template
<
typename
Char
>
struct
part_counter
{
public:
FMT_CONSTEXPR
part_counter
()
:
counter_
(
0u
)
{}
unsigned
num_parts
=
0
;
FMT_CONSTEXPR
void
on_text
(
const
Char
*
begin
,
const
Char
*
end
)
{
if
(
begin
!=
end
)
++
counter_
;
if
(
begin
!=
end
)
++
num_parts
;
}
FMT_CONSTEXPR
void
on_arg_id
()
{
++
counter_
;
}
FMT_CONSTEXPR
void
on_arg_id
(
unsigned
)
{
++
counter_
;
}
FMT_CONSTEXPR
void
on_arg_id
(
basic_string_view
<
Char
>
)
{
++
counter_
;
}
FMT_CONSTEXPR
void
on_arg_id
()
{
++
num_parts
;
}
FMT_CONSTEXPR
void
on_arg_id
(
unsigned
)
{
++
num_parts
;
}
FMT_CONSTEXPR
void
on_arg_id
(
basic_string_view
<
Char
>
)
{
++
num_parts
;
}
FMT_CONSTEXPR
void
on_replacement_field
(
const
Char
*
)
{}
...
...
@@ -290,11 +289,6 @@ template <typename Char> struct part_counter {
}
FMT_CONSTEXPR
void
on_error
(
const
char
*
)
{}
FMT_CONSTEXPR
unsigned
result
()
const
{
return
counter_
;
}
private:
unsigned
counter_
;
};
template
<
typename
Format
>
class
compiletime_prepared_parts_type_provider
{
...
...
@@ -305,7 +299,7 @@ template <typename Format> class compiletime_prepared_parts_type_provider {
FMT_CONSTEXPR_DECL
const
auto
text
=
to_string_view
(
Format
{});
part_counter
<
char_type
>
counter
;
internal
::
parse_format_string
<
/*IS_CONSTEXPR=*/
true
>
(
text
,
counter
);
return
counter
.
result
()
;
return
counter
.
num_parts
;
}
// Workaround for old compilers. Compiletime parts preparation will not be
...
...
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