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
1c8a8492
Commit
1c8a8492
authored
Dec 11, 2012
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix double action call issue.
parent
59536b15
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
format.h
format.h
+17
-2
No files found.
format.h
View file @
1c8a8492
...
...
@@ -237,6 +237,10 @@ class Formatter {
return
f
;
}
Formatter
*
formatter
()
const
{
return
formatter_
;
}
void
ResetFormatter
()
{
formatter_
=
0
;
}
public:
~
ArgInserter
()
{
if
(
formatter_
)
...
...
@@ -329,6 +333,8 @@ inline Formatter::ArgInserter Formatter::operator()(const char *format) {
}
// A formatter with an action performed when formatting is complete.
// This is a transient object that normally exists only as a temporary
// returned by one of the formatting functions.
template
<
typename
Action
>
class
ActiveFormatter
:
public
Formatter
::
ArgInserter
{
private:
...
...
@@ -348,10 +354,19 @@ class ActiveFormatter : public Formatter::ArgInserter {
ArgInserter
::
operator
=
(
formatter_
(
format
));
}
ActiveFormatter
(
ActiveFormatter
&
other
)
:
ArgInserter
(
other
)
{}
// Creates an active formatter with the same format string and action
// as other has and modifies other so that it doesn't call action in
// destructor. Note that the buffer content is not copied because the
// the buffer in ActiveFormatter is populated when all the arguments
// are provided.
ActiveFormatter
(
ActiveFormatter
&
other
)
:
action_
(
other
.
action_
)
{
other
.
ResetFormatter
();
ArgInserter
::
operator
=
(
formatter_
(
other
.
formatter_
.
format_
));
}
~
ActiveFormatter
()
{
action_
(
*
Format
());
if
(
formatter
())
action_
(
*
Format
());
}
};
...
...
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