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
e1ab6bc0
Commit
e1ab6bc0
authored
Aug 31, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify format string compilation
parent
24a88545
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
300 deletions
+72
-300
include/fmt/compile.h
include/fmt/compile.h
+72
-114
test/compile-test.cc
test/compile-test.cc
+0
-186
No files found.
include/fmt/compile.h
View file @
e1ab6bc0
This diff is collapsed.
Click to expand it.
test/compile-test.cc
View file @
e1ab6bc0
...
...
@@ -34,192 +34,6 @@
using
testing
::
Return
;
using
testing
::
StrictMock
;
FMT_BEGIN_NAMESPACE
namespace
internal
{
bool
operator
==
(
const
internal
::
string_view_metadata
&
lhs
,
const
internal
::
string_view_metadata
&
rhs
)
{
return
std
::
tie
(
lhs
.
offset_
,
lhs
.
size_
)
==
std
::
tie
(
rhs
.
offset_
,
rhs
.
size_
);
}
bool
operator
!=
(
const
internal
::
string_view_metadata
&
lhs
,
const
internal
::
string_view_metadata
&
rhs
)
{
return
!
(
lhs
==
rhs
);
}
bool
operator
==
(
const
format_part
<
char
>::
specification
&
lhs
,
const
format_part
<
char
>::
specification
&
rhs
)
{
if
(
lhs
.
arg_id
.
which
!=
rhs
.
arg_id
.
which
)
{
return
false
;
}
typedef
format_part
<
char
>::
argument_id
::
which_arg_id
which_arg_id
;
switch
(
lhs
.
arg_id
.
which
)
{
case
which_arg_id
:
:
index
:
{
if
(
lhs
.
arg_id
.
val
.
index
!=
rhs
.
arg_id
.
val
.
index
)
{
return
false
;
}
}
break
;
case
which_arg_id
:
:
named_index
:
{
if
(
lhs
.
arg_id
.
val
.
named_index
!=
rhs
.
arg_id
.
val
.
named_index
)
{
return
false
;
}
}
break
;
}
return
std
::
tie
(
lhs
.
parsed_specs
.
width
,
lhs
.
parsed_specs
.
fill
[
0
],
lhs
.
parsed_specs
.
align
,
lhs
.
parsed_specs
.
precision
,
lhs
.
parsed_specs
.
sign
,
lhs
.
parsed_specs
.
type
)
==
std
::
tie
(
rhs
.
parsed_specs
.
width
,
rhs
.
parsed_specs
.
fill
[
0
],
rhs
.
parsed_specs
.
align
,
rhs
.
parsed_specs
.
precision
,
rhs
.
parsed_specs
.
sign
,
rhs
.
parsed_specs
.
type
);
}
bool
operator
!=
(
const
format_part
<
char
>::
specification
&
lhs
,
const
format_part
<
char
>::
specification
&
rhs
)
{
return
!
(
lhs
==
rhs
);
}
bool
operator
==
(
const
format_part
<
char
>&
lhs
,
const
fmt
::
internal
::
format_part
<
char
>&
rhs
)
{
typedef
format_part
<
char
>::
kind
kind
;
if
(
lhs
.
which
!=
rhs
.
which
||
lhs
.
end_of_argument_id
!=
rhs
.
end_of_argument_id
)
{
return
false
;
}
switch
(
lhs
.
which
)
{
case
kind
:
:
argument_id
:
{
return
lhs
.
val
.
arg_id
==
rhs
.
val
.
arg_id
;
}
case
kind
:
:
named_argument_id
:
{
return
lhs
.
val
.
named_arg_id
==
rhs
.
val
.
named_arg_id
;
}
case
kind
:
:
text
:
{
return
lhs
.
val
.
text
==
rhs
.
val
.
text
;
}
case
kind
:
:
specification
:
{
return
lhs
.
val
.
spec
==
rhs
.
val
.
spec
;
}
}
return
false
;
}
bool
operator
!=
(
const
fmt
::
internal
::
format_part
<
char
>&
lhs
,
const
fmt
::
internal
::
format_part
<
char
>&
rhs
)
{
return
!
(
lhs
==
rhs
);
}
}
FMT_END_NAMESPACE
TEST
(
CompileTest
,
FormatPart_ComparisonOperators
)
{
typedef
fmt
::
internal
::
format_part
<
char
>
format_part
;
typedef
fmt
::
internal
::
dynamic_format_specs
<
char
>
prepared_specs
;
{
const
auto
part
=
format_part
(
0u
);
const
auto
other
=
format_part
(
0u
);
EXPECT_EQ
(
part
,
other
);
}
{
const
auto
lhs
=
format_part
(
0u
);
const
auto
rhs
=
format_part
(
1u
);
EXPECT_NE
(
lhs
,
rhs
);
}
{
const
auto
lhs
=
format_part
(
fmt
::
internal
::
string_view_metadata
(
0
,
42
));
const
auto
rhs
=
format_part
(
fmt
::
internal
::
string_view_metadata
(
0
,
42
));
EXPECT_EQ
(
lhs
,
rhs
);
}
{
const
auto
lhs
=
format_part
(
fmt
::
internal
::
string_view_metadata
(
0
,
42
));
const
auto
rhs
=
format_part
(
fmt
::
internal
::
string_view_metadata
(
0
,
4422
));
EXPECT_NE
(
lhs
,
rhs
);
}
{
auto
lhs
=
format_part
(
0u
);
auto
rhs
=
format_part
(
fmt
::
internal
::
string_view_metadata
(
0
,
42
));
EXPECT_NE
(
lhs
,
rhs
);
rhs
=
format_part
(
fmt
::
internal
::
string_view_metadata
(
0
,
0
));
EXPECT_NE
(
lhs
,
rhs
);
}
{
auto
lhs
=
format_part
(
0u
);
lhs
.
end_of_argument_id
=
42
;
auto
rhs
=
format_part
(
0u
);
rhs
.
end_of_argument_id
=
42
;
EXPECT_EQ
(
lhs
,
rhs
);
rhs
.
end_of_argument_id
=
13
;
EXPECT_NE
(
lhs
,
rhs
);
}
{
const
auto
specs_argument_id
=
0u
;
const
auto
specs_named_argument_id
=
fmt
::
internal
::
string_view_metadata
(
0
,
42
);
auto
specs
=
format_part
::
specification
(
0u
);
auto
lhs
=
format_part
(
specs
);
auto
rhs
=
format_part
(
specs
);
EXPECT_EQ
(
lhs
,
rhs
);
specs
.
parsed_specs
=
prepared_specs
();
lhs
=
format_part
(
specs
);
rhs
=
format_part
(
specs
);
EXPECT_EQ
(
lhs
,
rhs
);
specs
=
format_part
::
specification
(
specs_named_argument_id
);
lhs
=
format_part
(
specs
);
rhs
=
format_part
(
specs
);
EXPECT_EQ
(
lhs
,
rhs
);
specs
.
parsed_specs
=
prepared_specs
();
lhs
=
format_part
(
specs
);
rhs
=
format_part
(
specs
);
EXPECT_EQ
(
lhs
,
rhs
);
auto
lhs_spec
=
format_part
::
specification
(
specs_argument_id
);
auto
rhs_spec
=
format_part
::
specification
(
specs_named_argument_id
);
lhs
=
format_part
(
lhs_spec
);
rhs
=
format_part
(
rhs_spec
);
EXPECT_NE
(
lhs
,
rhs
);
lhs_spec
=
format_part
::
specification
(
specs_argument_id
);
rhs_spec
=
format_part
::
specification
(
specs_argument_id
);
lhs_spec
.
parsed_specs
.
precision
=
1
;
rhs_spec
.
parsed_specs
.
precision
=
2
;
lhs
=
format_part
(
lhs_spec
);
rhs
=
format_part
(
rhs_spec
);
EXPECT_NE
(
lhs
,
rhs
);
}
{
const
auto
specs_argument_id
=
0u
;
const
auto
specs_named_argument_id
=
fmt
::
internal
::
string_view_metadata
(
0
,
42
);
auto
specs
=
format_part
::
specification
(
specs_argument_id
);
auto
lhs
=
format_part
(
specs
);
auto
rhs
=
format_part
(
0u
);
auto
rhs2
=
format_part
(
fmt
::
internal
::
string_view_metadata
(
0
,
42
));
EXPECT_NE
(
lhs
,
rhs
);
EXPECT_NE
(
lhs
,
rhs2
);
specs
.
parsed_specs
=
prepared_specs
();
lhs
=
format_part
{
specs
};
EXPECT_NE
(
lhs
,
rhs
);
EXPECT_NE
(
lhs
,
rhs2
);
specs
=
format_part
::
specification
(
specs_named_argument_id
);
EXPECT_NE
(
lhs
,
rhs
);
EXPECT_NE
(
lhs
,
rhs2
);
specs
.
parsed_specs
=
prepared_specs
();
lhs
=
format_part
(
specs
);
EXPECT_NE
(
lhs
,
rhs
);
EXPECT_NE
(
lhs
,
rhs2
);
}
}
// compiletime_prepared_parts_type_provider is useful only with relaxed
// constexpr.
#if FMT_USE_CONSTEXPR
...
...
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