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
c58b7d9c
Commit
c58b7d9c
authored
Nov 13, 2019
by
Daniel Laügt
Committed by
Victor Zverovich
Nov 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use overridden locale in ostream
parent
ceff9b0b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
include/fmt/core.h
include/fmt/core.h
+2
-0
include/fmt/ostream.h
include/fmt/ostream.h
+4
-2
No files found.
include/fmt/core.h
View file @
c58b7d9c
...
@@ -1076,6 +1076,8 @@ class locale_ref {
...
@@ -1076,6 +1076,8 @@ class locale_ref {
locale_ref
()
:
locale_
(
nullptr
)
{}
locale_ref
()
:
locale_
(
nullptr
)
{}
template
<
typename
Locale
>
explicit
locale_ref
(
const
Locale
&
loc
);
template
<
typename
Locale
>
explicit
locale_ref
(
const
Locale
&
loc
);
explicit
operator
bool
()
const
FMT_NOEXCEPT
{
return
locale_
!=
nullptr
;
}
template
<
typename
Locale
>
Locale
get
()
const
;
template
<
typename
Locale
>
Locale
get
()
const
;
};
};
...
...
include/fmt/ostream.h
View file @
c58b7d9c
...
@@ -89,9 +89,11 @@ void write(std::basic_ostream<Char>& os, buffer<Char>& buf) {
...
@@ -89,9 +89,11 @@ void write(std::basic_ostream<Char>& os, buffer<Char>& buf) {
}
}
template
<
typename
Char
,
typename
T
>
template
<
typename
Char
,
typename
T
>
void
format_value
(
buffer
<
Char
>&
buf
,
const
T
&
value
)
{
void
format_value
(
buffer
<
Char
>&
buf
,
const
T
&
value
,
locale_ref
loc
=
locale_ref
())
{
formatbuf
<
Char
>
format_buf
(
buf
);
formatbuf
<
Char
>
format_buf
(
buf
);
std
::
basic_ostream
<
Char
>
output
(
&
format_buf
);
std
::
basic_ostream
<
Char
>
output
(
&
format_buf
);
if
(
loc
)
output
.
imbue
(
loc
.
get
<
std
::
locale
>
());
output
.
exceptions
(
std
::
ios_base
::
failbit
|
std
::
ios_base
::
badbit
);
output
.
exceptions
(
std
::
ios_base
::
failbit
|
std
::
ios_base
::
badbit
);
output
<<
value
;
output
<<
value
;
buf
.
resize
(
buf
.
size
());
buf
.
resize
(
buf
.
size
());
...
@@ -104,7 +106,7 @@ struct fallback_formatter<T, Char, enable_if_t<is_streamable<T, Char>::value>>
...
@@ -104,7 +106,7 @@ struct fallback_formatter<T, Char, enable_if_t<is_streamable<T, Char>::value>>
template
<
typename
Context
>
template
<
typename
Context
>
auto
format
(
const
T
&
value
,
Context
&
ctx
)
->
decltype
(
ctx
.
out
())
{
auto
format
(
const
T
&
value
,
Context
&
ctx
)
->
decltype
(
ctx
.
out
())
{
basic_memory_buffer
<
Char
>
buffer
;
basic_memory_buffer
<
Char
>
buffer
;
format_value
(
buffer
,
value
);
format_value
(
buffer
,
value
,
ctx
.
locale
()
);
basic_string_view
<
Char
>
str
(
buffer
.
data
(),
buffer
.
size
());
basic_string_view
<
Char
>
str
(
buffer
.
data
(),
buffer
.
size
());
return
formatter
<
basic_string_view
<
Char
>
,
Char
>::
format
(
str
,
ctx
);
return
formatter
<
basic_string_view
<
Char
>
,
Char
>::
format
(
str
,
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