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
466128de
Commit
466128de
authored
Sep 01, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unused code and refactor
parent
22e98a5b
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
109 additions
and
155 deletions
+109
-155
include/fmt/chrono.h
include/fmt/chrono.h
+3
-3
include/fmt/compile.h
include/fmt/compile.h
+95
-106
include/fmt/format.h
include/fmt/format.h
+6
-9
test/compile-test.cc
test/compile-test.cc
+3
-35
test/format
test/format
+2
-2
No files found.
include/fmt/chrono.h
View file @
466128de
...
...
@@ -805,10 +805,10 @@ struct formatter<std::chrono::duration<Rep, Period>, Char> {
auto
out
=
std
::
back_inserter
(
buf
);
using
range
=
internal
::
output_range
<
decltype
(
ctx
.
out
()),
Char
>
;
internal
::
basic_writer
<
range
>
w
(
range
(
ctx
.
out
()));
internal
::
handle_dynamic_spec
<
internal
::
width_checker
>
(
specs
.
width
,
width_ref
,
ctx
,
format_str
.
begin
()
);
internal
::
handle_dynamic_spec
<
internal
::
width_checker
>
(
specs
.
width
,
width_ref
,
ctx
);
internal
::
handle_dynamic_spec
<
internal
::
precision_checker
>
(
precision
,
precision_ref
,
ctx
,
format_str
.
begin
()
);
precision
,
precision_ref
,
ctx
);
if
(
begin
==
end
||
*
begin
==
'}'
)
{
out
=
internal
::
format_chrono_duration_value
(
out
,
d
.
count
(),
precision
);
internal
::
format_chrono_duration_unit
<
Period
>
(
out
);
...
...
include/fmt/compile.h
View file @
466128de
This diff is collapsed.
Click to expand it.
include/fmt/format.h
View file @
466128de
...
...
@@ -2556,8 +2556,7 @@ void check_format_string(S format_str) {
template
<
template
<
typename
>
class
Handler
,
typename
Spec
,
typename
Context
>
void
handle_dynamic_spec
(
Spec
&
value
,
arg_ref
<
typename
Context
::
char_type
>
ref
,
Context
&
ctx
,
const
typename
Context
::
char_type
*
format_str
)
{
Context
&
ctx
)
{
switch
(
ref
.
kind
)
{
case
arg_id_kind
:
:
none
:
break
;
...
...
@@ -2935,13 +2934,12 @@ template <typename T, typename Char>
struct
formatter
<
T
,
Char
,
enable_if_t
<
internal
::
type_constant
<
T
,
Char
>::
value
!=
internal
::
custom_type
>>
{
FMT_CONSTEXPR
formatter
()
:
format_str_
(
nullptr
)
{}
FMT_CONSTEXPR
formatter
()
{}
// Parses format specifiers stopping either at the end of the range or at the
// terminating '}'.
template
<
typename
ParseContext
>
FMT_CONSTEXPR
auto
parse
(
ParseContext
&
ctx
)
->
decltype
(
ctx
.
begin
())
{
format_str_
=
ctx
.
begin
();
using
handler_type
=
internal
::
dynamic_specs_handler
<
ParseContext
>
;
auto
type
=
internal
::
type_constant
<
T
,
Char
>::
value
;
internal
::
specs_checker
<
handler_type
>
handler
(
handler_type
(
specs_
,
ctx
),
...
...
@@ -2991,9 +2989,9 @@ struct formatter<T, Char,
template
<
typename
FormatContext
>
auto
format
(
const
T
&
val
,
FormatContext
&
ctx
)
->
decltype
(
ctx
.
out
())
{
internal
::
handle_dynamic_spec
<
internal
::
width_checker
>
(
specs_
.
width
,
specs_
.
width_ref
,
ctx
,
format_str_
);
specs_
.
width
,
specs_
.
width_ref
,
ctx
);
internal
::
handle_dynamic_spec
<
internal
::
precision_checker
>
(
specs_
.
precision
,
specs_
.
precision_ref
,
ctx
,
format_str_
);
specs_
.
precision
,
specs_
.
precision_ref
,
ctx
);
using
range_type
=
internal
::
output_range
<
typename
FormatContext
::
iterator
,
typename
FormatContext
::
char_type
>
;
...
...
@@ -3003,7 +3001,6 @@ struct formatter<T, Char,
private:
internal
::
dynamic_format_specs
<
Char
>
specs_
;
const
Char
*
format_str_
;
};
#define FMT_FORMAT_AS(Type, Base) \
...
...
@@ -3104,9 +3101,9 @@ template <typename Char = char> class dynamic_formatter {
private:
template
<
typename
Context
>
void
handle_specs
(
Context
&
ctx
)
{
internal
::
handle_dynamic_spec
<
internal
::
width_checker
>
(
specs_
.
width
,
specs_
.
width_ref
,
ctx
,
format_str_
);
specs_
.
width
,
specs_
.
width_ref
,
ctx
);
internal
::
handle_dynamic_spec
<
internal
::
precision_checker
>
(
specs_
.
precision
,
specs_
.
precision_ref
,
ctx
,
format_str_
);
specs_
.
precision
,
specs_
.
precision_ref
,
ctx
);
}
internal
::
dynamic_format_specs
<
Char
>
specs_
;
...
...
test/compile-test.cc
View file @
466128de
...
...
@@ -67,40 +67,6 @@ TEST(CompileTest, CompileTimePreparedPartsTypeProvider) {
}
#endif
class
custom_parts_container
{
public:
typedef
fmt
::
internal
::
format_part
<
char
>
format_part_type
;
private:
typedef
std
::
deque
<
format_part_type
>
parts
;
public:
void
add
(
format_part_type
part
)
{
parts_
.
push_back
(
std
::
move
(
part
));
}
void
substitute_last
(
format_part_type
part
)
{
parts_
.
back
()
=
std
::
move
(
part
);
}
format_part_type
last
()
{
return
parts_
.
back
();
}
auto
begin
()
->
decltype
(
std
::
declval
<
parts
>
().
begin
())
{
return
parts_
.
begin
();
}
auto
begin
()
const
->
decltype
(
std
::
declval
<
const
parts
>
().
begin
())
{
return
parts_
.
begin
();
}
auto
end
()
->
decltype
(
std
::
declval
<
parts
>
().
begin
())
{
return
parts_
.
end
();
}
auto
end
()
const
->
decltype
(
std
::
declval
<
const
parts
>
().
begin
())
{
return
parts_
.
end
();
}
private:
parts
parts_
;
};
TEST
(
CompileTest
,
PassStringLiteralFormat
)
{
const
auto
prepared
=
fmt
::
compile
<
int
>
(
"test {}"
);
EXPECT_EQ
(
"test 42"
,
fmt
::
format
(
prepared
,
42
));
...
...
@@ -155,12 +121,14 @@ TEST(CompileTest, FormattedSize) {
struct
formattable
{};
FMT_BEGIN_NAMESPACE
template
<
>
struct
f
mt
::
f
ormatter
<
formattable
>
:
formatter
<
const
char
*>
{
struct
formatter
<
formattable
>
:
formatter
<
const
char
*>
{
auto
format
(
formattable
,
format_context
&
ctx
)
->
decltype
(
ctx
.
out
())
{
return
formatter
<
const
char
*>::
format
(
"foo"
,
ctx
);
}
};
FMT_END_NAMESPACE
TEST
(
CompileTest
,
FormatUserDefinedType
)
{
auto
f
=
fmt
::
compile
<
formattable
>
(
"{}"
);
...
...
test/format
View file @
466128de
...
...
@@ -690,9 +690,9 @@ struct formatter {
template <typename FormatContext>
auto format(const T& val, FormatContext& ctx) -> decltype(ctx.out()) {
fmt::internal::handle_dynamic_spec<fmt::internal::width_checker>(
specs_.width, specs_.width_ref, ctx
, nullptr
);
specs_.width, specs_.width_ref, ctx);
fmt::internal::handle_dynamic_spec<fmt::internal::precision_checker>(
specs_.precision, specs_.precision_ref, ctx
, nullptr
);
specs_.precision, specs_.precision_ref, ctx);
using range_type = fmt::internal::output_range<typename FormatContext::iterator,
typename FormatContext::char_type>;
return visit_format_arg(arg_formatter<range_type>(ctx, nullptr, &specs_),
...
...
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