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
3d11eac7
Commit
3d11eac7
authored
Oct 21, 2017
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Workaround another MSVC constexpr bug
parent
25aac0be
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
40 deletions
+40
-40
fmt/format.h
fmt/format.h
+40
-40
No files found.
fmt/format.h
View file @
3d11eac7
...
...
@@ -3070,7 +3070,7 @@ struct is_integer {
};
};
struct
width_
handl
er
{
struct
width_
check
er
{
template
<
typename
T
>
typename
std
::
enable_if
<
is_integer
<
T
>::
value
,
unsigned
long
long
>::
type
operator
()(
T
value
)
{
...
...
@@ -3087,7 +3087,7 @@ struct width_handler {
}
};
struct
precision_
handl
er
{
struct
precision_
check
er
{
template
<
typename
T
>
typename
std
::
enable_if
<
is_integer
<
T
>::
value
,
unsigned
long
long
>::
type
operator
()(
T
value
)
{
...
...
@@ -3234,13 +3234,13 @@ class specs_handler: public specs_setter<typename Context::char_type> {
template
<
typename
Id
>
void
on_dynamic_width
(
Id
arg_id
)
{
set_dynamic_spec
<
internal
::
width_
handl
er
>
(
set_dynamic_spec
<
internal
::
width_
check
er
>
(
this
->
specs_
.
width_
,
get_arg
(
arg_id
));
}
template
<
typename
Id
>
void
on_dynamic_precision
(
Id
arg_id
)
{
set_dynamic_spec
<
internal
::
precision_
handl
er
>
(
set_dynamic_spec
<
internal
::
precision_
check
er
>
(
this
->
specs_
.
precision_
,
get_arg
(
arg_id
));
}
...
...
@@ -3361,6 +3361,36 @@ constexpr Iterator parse_arg_id(Iterator it, Handler& handler) {
return
it
;
}
template
<
typename
Handler
,
typename
Char
>
struct
width_handler
{
explicit
constexpr
width_handler
(
Handler
&
h
)
:
handler
(
h
)
{}
constexpr
void
operator
()()
{
handler
.
on_dynamic_width
(
auto_id
());
}
constexpr
void
operator
()(
unsigned
id
)
{
handler
.
on_dynamic_width
(
id
);
}
constexpr
void
operator
()(
basic_string_view
<
Char
>
id
)
{
handler
.
on_dynamic_width
(
id
);
}
constexpr
void
on_error
(
const
char
*
message
)
{
handler
.
on_error
(
message
);
}
Handler
&
handler
;
};
template
<
typename
Handler
,
typename
Char
>
struct
precision_handler
{
explicit
constexpr
precision_handler
(
Handler
&
h
)
:
handler
(
h
)
{}
constexpr
void
operator
()()
{
handler
.
on_dynamic_precision
(
auto_id
());
}
constexpr
void
operator
()(
unsigned
id
)
{
handler
.
on_dynamic_precision
(
id
);
}
constexpr
void
operator
()(
basic_string_view
<
Char
>
id
)
{
handler
.
on_dynamic_precision
(
id
);
}
constexpr
void
on_error
(
const
char
*
message
)
{
handler
.
on_error
(
message
);
}
Handler
&
handler
;
};
// Parses standard format specifiers and sends notifications about parsed
// components to handler.
// it: an iterator pointing to the beginning of a null-terminated range of
...
...
@@ -3436,21 +3466,7 @@ constexpr Iterator parse_format_specs(Iterator it, Handler &handler) {
if
(
'0'
<=
*
it
&&
*
it
<=
'9'
)
{
handler
.
on_width
(
parse_nonnegative_int
(
it
));
}
else
if
(
*
it
==
'{'
)
{
struct
width_handler
{
explicit
constexpr
width_handler
(
Handler
&
h
)
:
handler
(
h
)
{}
constexpr
void
operator
()()
{
handler
.
on_dynamic_width
(
auto_id
());
}
constexpr
void
operator
()(
unsigned
id
)
{
handler
.
on_dynamic_width
(
id
);
}
constexpr
void
operator
()(
basic_string_view
<
char_type
>
id
)
{
handler
.
on_dynamic_width
(
id
);
}
constexpr
void
on_error
(
const
char
*
message
)
{
handler
.
on_error
(
message
);
}
Handler
&
handler
;
}
wh
(
handler
);
width_handler
<
Handler
,
char_type
>
wh
(
handler
);
it
=
parse_arg_id
(
it
+
1
,
wh
);
if
(
*
it
++
!=
'}'
)
{
handler
.
on_error
(
"invalid format string"
);
...
...
@@ -3464,23 +3480,7 @@ constexpr Iterator parse_format_specs(Iterator it, Handler &handler) {
if
(
'0'
<=
*
it
&&
*
it
<=
'9'
)
{
handler
.
on_precision
(
parse_nonnegative_int
(
it
));
}
else
if
(
*
it
==
'{'
)
{
struct
precision_handler
{
explicit
constexpr
precision_handler
(
Handler
&
h
)
:
handler
(
h
)
{}
constexpr
void
operator
()()
{
handler
.
on_dynamic_precision
(
auto_id
());
}
constexpr
void
operator
()(
unsigned
id
)
{
handler
.
on_dynamic_precision
(
id
);
}
constexpr
void
operator
()(
basic_string_view
<
char_type
>
id
)
{
handler
.
on_dynamic_precision
(
id
);
}
constexpr
void
on_error
(
const
char
*
message
)
{
handler
.
on_error
(
message
);
}
Handler
&
handler
;
}
ph
(
handler
);
precision_handler
<
Handler
,
char_type
>
ph
(
handler
);
it
=
parse_arg_id
(
it
+
1
,
ph
);
if
(
*
it
++
!=
'}'
)
{
handler
.
on_error
(
"invalid format string"
);
...
...
@@ -3567,9 +3567,9 @@ struct formatter<
}
void
format
(
basic_buffer
<
Char
>
&
buf
,
const
T
&
val
,
basic_context
<
Char
>
&
ctx
)
{
internal
::
handle_dynamic_spec
<
internal
::
width_
handl
er
>
(
internal
::
handle_dynamic_spec
<
internal
::
width_
check
er
>
(
specs_
.
width_
,
specs_
.
width_ref
,
ctx
);
internal
::
handle_dynamic_spec
<
internal
::
precision_
handl
er
>
(
internal
::
handle_dynamic_spec
<
internal
::
precision_
check
er
>
(
specs_
.
precision_
,
specs_
.
precision_ref
,
ctx
);
visit
(
arg_formatter
<
Char
>
(
buf
,
ctx
,
specs_
),
internal
::
make_arg
<
basic_context
<
Char
>>
(
val
));
...
...
@@ -3645,9 +3645,9 @@ struct dynamic_formatter {
private:
void
handle_specs
(
basic_context
<
Char
>
&
ctx
)
{
internal
::
handle_dynamic_spec
<
internal
::
width_
handl
er
>
(
internal
::
handle_dynamic_spec
<
internal
::
width_
check
er
>
(
specs_
.
width_
,
specs_
.
width_ref
,
ctx
);
internal
::
handle_dynamic_spec
<
internal
::
precision_
handl
er
>
(
internal
::
handle_dynamic_spec
<
internal
::
precision_
check
er
>
(
specs_
.
precision_
,
specs_
.
precision_ref
,
ctx
);
}
...
...
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