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
b09f3713
Commit
b09f3713
authored
Feb 05, 2013
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement a workaround for older GCC.
parent
74494c29
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
11 deletions
+13
-11
format.h
format.h
+13
-11
No files found.
format.h
View file @
b09f3713
...
...
@@ -811,6 +811,15 @@ void Format(BasicWriter<Char> &f, const FormatSpec &spec, const T &value) {
f
.
Write
(
os
.
str
(),
spec
);
}
namespace
internal
{
// Formats an argument of a custom type, such as a user-defined class.
template
<
typename
Char
,
typename
T
>
void
FormatCustomArg
(
BasicWriter
<
Char
>
&
w
,
const
void
*
arg
,
const
FormatSpec
&
spec
)
{
Format
(
w
,
spec
,
*
static_cast
<
const
T
*>
(
arg
));
}
}
/**
\rst
The :cpp:class:`fmt::BasicFormatter` template provides string formatting
...
...
@@ -845,8 +854,8 @@ class BasicFormatter : public BasicWriter<Char> {
CHAR
,
STRING
,
WSTRING
,
POINTER
,
CUSTOM
};
typedef
void
(
BasicFormatter
::
*
FormatFunc
)(
const
void
*
arg
,
const
FormatSpec
&
spec
);
typedef
void
(
*
FormatFunc
)(
BasicWriter
<
Char
>
&
w
,
const
void
*
arg
,
const
FormatSpec
&
spec
);
// A format argument.
class
Arg
{
...
...
@@ -919,7 +928,7 @@ class BasicFormatter : public BasicWriter<Char> {
template
<
typename
T
>
Arg
(
const
T
&
value
)
:
type
(
CUSTOM
),
formatter
(
0
)
{
custom
.
value
=
&
value
;
custom
.
format
=
&
BasicFormatter
<
Char
>::
FormatCustomArg
<
T
>
;
custom
.
format
=
&
internal
::
FormatCustomArg
<
Char
,
T
>
;
}
~
Arg
()
{
...
...
@@ -954,13 +963,6 @@ class BasicFormatter : public BasicWriter<Char> {
void
ReportError
(
const
char
*
s
,
StringRef
message
)
const
;
// Formats an argument of a custom type, such as a user-defined class.
template
<
typename
T
>
void
FormatCustomArg
(
const
void
*
arg
,
const
FormatSpec
&
spec
)
{
BasicWriter
<
Char
>
&
f
=
*
this
;
Format
(
f
,
spec
,
*
static_cast
<
const
T
*>
(
arg
));
}
unsigned
ParseUInt
(
const
char
*&
s
)
const
;
// Parses argument index and returns an argument with this index.
...
...
@@ -1514,7 +1516,7 @@ void BasicFormatter<Char>::DoFormat() {
case
CUSTOM
:
if
(
spec
.
type_
)
internal
::
ReportUnknownType
(
spec
.
type_
,
"object"
);
(
this
->*
arg
.
custom
.
format
)(
arg
.
custom
.
value
,
spec
);
arg
.
custom
.
format
(
*
this
,
arg
.
custom
.
value
,
spec
);
break
;
default:
assert
(
false
);
...
...
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