Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spdlog
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
spdlog
Commits
2b81c40b
Commit
2b81c40b
authored
Dec 11, 2020
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bump fmt to version 7.1.3
parent
233e97c5
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
2982 additions
and
1019 deletions
+2982
-1019
include/spdlog/fmt/bundled/chrono.h
include/spdlog/fmt/bundled/chrono.h
+37
-42
include/spdlog/fmt/bundled/color.h
include/spdlog/fmt/bundled/color.h
+47
-10
include/spdlog/fmt/bundled/compile.h
include/spdlog/fmt/bundled/compile.h
+59
-23
include/spdlog/fmt/bundled/core.h
include/spdlog/fmt/bundled/core.h
+344
-104
include/spdlog/fmt/bundled/format-inl.h
include/spdlog/fmt/bundled/format-inl.h
+1621
-273
include/spdlog/fmt/bundled/format.h
include/spdlog/fmt/bundled/format.h
+694
-463
include/spdlog/fmt/bundled/locale.h
include/spdlog/fmt/bundled/locale.h
+15
-29
include/spdlog/fmt/bundled/os.h
include/spdlog/fmt/bundled/os.h
+67
-37
include/spdlog/fmt/bundled/ostream.h
include/spdlog/fmt/bundled/ostream.h
+19
-9
include/spdlog/fmt/bundled/printf.h
include/spdlog/fmt/bundled/printf.h
+2
-2
include/spdlog/fmt/bundled/ranges.h
include/spdlog/fmt/bundled/ranges.h
+16
-6
src/fmt.cpp
src/fmt.cpp
+61
-21
No files found.
include/spdlog/fmt/bundled/chrono.h
View file @
2b81c40b
...
...
@@ -72,43 +72,27 @@ FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) {
static_assert
(
F
::
is_integer
,
"From must be integral"
);
static_assert
(
T
::
is_integer
,
"To must be integral"
);
if
(
F
::
is_signed
&&
!
T
::
is_signed
)
{
if
(
detail
::
const_check
(
F
::
is_signed
&&
!
T
::
is_signed
)
)
{
// From may be negative, not allowed!
if
(
fmt
::
detail
::
is_negative
(
from
))
{
ec
=
1
;
return
{};
}
// From is positive. Can it always fit in To?
if
(
F
::
digits
<=
T
::
digits
)
{
// yes, From always fits in To.
}
else
{
// from may not fit in To, we have to do a dynamic check
if
(
from
>
static_cast
<
From
>
((
T
::
max
)()))
{
if
(
F
::
digits
>
T
::
digits
&&
from
>
static_cast
<
From
>
(
detail
::
max_value
<
To
>
()))
{
ec
=
1
;
return
{};
}
}
}
if
(
!
F
::
is_signed
&&
T
::
is_signed
)
{
// can from be held in To?
if
(
F
::
digits
<
T
::
digits
)
{
// yes, From always fits in To.
}
else
{
// from may not fit in To, we have to do a dynamic check
if
(
from
>
static_cast
<
From
>
((
T
::
max
)()))
{
// outside range.
if
(
!
F
::
is_signed
&&
T
::
is_signed
&&
F
::
digits
>=
T
::
digits
&&
from
>
static_cast
<
From
>
(
detail
::
max_value
<
To
>
()))
{
ec
=
1
;
return
{};
}
}
}
// reaching here means all is ok for lossless conversion.
return
static_cast
<
To
>
(
from
);
}
// function
return
static_cast
<
To
>
(
from
);
// Lossless conversion.
}
template
<
typename
To
,
typename
From
,
FMT_ENABLE_IF
(
std
::
is_same
<
From
,
To
>
::
value
)
>
...
...
@@ -190,11 +174,9 @@ To safe_duration_cast(std::chrono::duration<FromRep, FromPeriod> from,
// safe conversion to IntermediateRep
IntermediateRep
count
=
lossless_integral_conversion
<
IntermediateRep
>
(
from
.
count
(),
ec
);
if
(
ec
)
{
return
{};
}
if
(
ec
)
return
{};
// multiply with Factor::num without overflow or underflow
if
(
Factor
::
num
!=
1
)
{
if
(
detail
::
const_check
(
Factor
::
num
!=
1
)
)
{
const
auto
max1
=
detail
::
max_value
<
IntermediateRep
>
()
/
Factor
::
num
;
if
(
count
>
max1
)
{
ec
=
1
;
...
...
@@ -209,17 +191,9 @@ To safe_duration_cast(std::chrono::duration<FromRep, FromPeriod> from,
count
*=
Factor
::
num
;
}
// this can't go wrong, right? den>0 is checked earlier.
if
(
Factor
::
den
!=
1
)
{
count
/=
Factor
::
den
;
}
// convert to the to type, safely
using
ToRep
=
typename
To
::
rep
;
const
ToRep
tocount
=
lossless_integral_conversion
<
ToRep
>
(
count
,
ec
);
if
(
ec
)
{
return
{};
}
return
To
{
tocount
};
if
(
detail
::
const_check
(
Factor
::
den
!=
1
))
count
/=
Factor
::
den
;
auto
tocount
=
lossless_integral_conversion
<
typename
To
::
rep
>
(
count
,
ec
);
return
ec
?
To
()
:
To
(
tocount
);
}
/**
...
...
@@ -351,6 +325,11 @@ inline std::tm localtime(std::time_t time) {
return
lt
.
tm_
;
}
inline
std
::
tm
localtime
(
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
>
time_point
)
{
return
localtime
(
std
::
chrono
::
system_clock
::
to_time_t
(
time_point
));
}
// Thread-safe replacement for std::gmtime
inline
std
::
tm
gmtime
(
std
::
time_t
time
)
{
struct
dispatcher
{
...
...
@@ -387,6 +366,11 @@ inline std::tm gmtime(std::time_t time) {
return
gt
.
tm_
;
}
inline
std
::
tm
gmtime
(
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
>
time_point
)
{
return
gmtime
(
std
::
chrono
::
system_clock
::
to_time_t
(
time_point
));
}
namespace
detail
{
inline
size_t
strftime
(
char
*
str
,
size_t
count
,
const
char
*
format
,
const
std
::
tm
*
time
)
{
...
...
@@ -399,6 +383,17 @@ inline size_t strftime(wchar_t* str, size_t count, const wchar_t* format,
}
}
// namespace detail
template
<
typename
Char
>
struct
formatter
<
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
>
,
Char
>
:
formatter
<
std
::
tm
,
Char
>
{
template
<
typename
FormatContext
>
auto
format
(
std
::
chrono
::
time_point
<
std
::
chrono
::
system_clock
>
val
,
FormatContext
&
ctx
)
->
decltype
(
ctx
.
out
())
{
std
::
tm
time
=
localtime
(
val
);
return
formatter
<
std
::
tm
,
Char
>::
format
(
time
,
ctx
);
}
};
template
<
typename
Char
>
struct
formatter
<
std
::
tm
,
Char
>
{
template
<
typename
ParseContext
>
auto
parse
(
ParseContext
&
ctx
)
->
decltype
(
ctx
.
begin
())
{
...
...
include/spdlog/fmt/bundled/color.h
View file @
2b81c40b
...
...
@@ -463,16 +463,16 @@ template <> inline void reset_color<wchar_t>(FILE* stream) FMT_NOEXCEPT {
}
template
<
typename
Char
>
inline
void
reset_color
(
b
asic_memory_b
uffer
<
Char
>&
buffer
)
FMT_NOEXCEPT
{
inline
void
reset_color
(
buffer
<
Char
>&
buffer
)
FMT_NOEXCEPT
{
const
char
*
begin
=
data
::
reset_color
;
const
char
*
end
=
begin
+
sizeof
(
data
::
reset_color
)
-
1
;
buffer
.
append
(
begin
,
end
);
}
template
<
typename
Char
>
void
vformat_to
(
b
asic_memory_b
uffer
<
Char
>&
buf
,
const
text_style
&
ts
,
void
vformat_to
(
buffer
<
Char
>&
buf
,
const
text_style
&
ts
,
basic_string_view
<
Char
>
format_str
,
basic_format_args
<
buffer_context
<
Char
>>
args
)
{
basic_format_args
<
buffer_context
<
type_identity_t
<
Char
>
>>
args
)
{
bool
has_style
=
false
;
if
(
ts
.
has_emphasis
())
{
has_style
=
true
;
...
...
@@ -496,7 +496,7 @@ void vformat_to(basic_memory_buffer<Char>& buf, const text_style& ts,
template
<
typename
S
,
typename
Char
=
char_t
<
S
>
>
void
vprint
(
std
::
FILE
*
f
,
const
text_style
&
ts
,
const
S
&
format
,
basic_format_args
<
buffer_context
<
Char
>>
args
)
{
basic_format_args
<
buffer_context
<
type_identity_t
<
Char
>
>>
args
)
{
basic_memory_buffer
<
Char
>
buf
;
detail
::
vformat_to
(
buf
,
ts
,
to_string_view
(
format
),
args
);
buf
.
push_back
(
Char
(
0
));
...
...
@@ -504,20 +504,22 @@ void vprint(std::FILE* f, const text_style& ts, const S& format,
}
/**
\rst
Formats a string and prints it to the specified file stream using ANSI
escape sequences to specify text formatting.
Example:
**Example**::
fmt::print(fmt::emphasis::bold | fg(fmt::color::red),
"Elapsed time: {0:.2f} seconds", 1.23);
\endrst
*/
template
<
typename
S
,
typename
...
Args
,
FMT_ENABLE_IF
(
detail
::
is_string
<
S
>
::
value
)
>
void
print
(
std
::
FILE
*
f
,
const
text_style
&
ts
,
const
S
&
format_str
,
const
Args
&
...
args
)
{
detail
::
check_format_string
<
Args
...
>
(
format_str
);
using
context
=
buffer_context
<
char_t
<
S
>>
;
format_arg_store
<
context
,
Args
...
>
as
{
args
...};
vprint
(
f
,
ts
,
format_str
,
basic_format_args
<
context
>
(
as
));
vprint
(
f
,
ts
,
format_str
,
fmt
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...));
}
/**
...
...
@@ -558,7 +560,42 @@ template <typename S, typename... Args, typename Char = char_t<S>>
inline
std
::
basic_string
<
Char
>
format
(
const
text_style
&
ts
,
const
S
&
format_str
,
const
Args
&
...
args
)
{
return
vformat
(
ts
,
to_string_view
(
format_str
),
detail
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...));
fmt
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...));
}
/**
Formats a string with the given text_style and writes the output to ``out``.
*/
template
<
typename
OutputIt
,
typename
Char
,
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
,
Char
>
::
value
)
>
OutputIt
vformat_to
(
OutputIt
out
,
const
text_style
&
ts
,
basic_string_view
<
Char
>
format_str
,
basic_format_args
<
buffer_context
<
type_identity_t
<
Char
>>>
args
)
{
decltype
(
detail
::
get_buffer
<
Char
>
(
out
))
buf
(
detail
::
get_buffer_init
(
out
));
detail
::
vformat_to
(
buf
,
ts
,
format_str
,
args
);
return
detail
::
get_iterator
(
buf
);
}
/**
\rst
Formats arguments with the given text_style, writes the result to the output
iterator ``out`` and returns the iterator past the end of the output range.
**Example**::
std::vector<char> out;
fmt::format_to(std::back_inserter(out),
fmt::emphasis::bold | fg(fmt::color::red), "{}", 42);
\endrst
*/
template
<
typename
OutputIt
,
typename
S
,
typename
...
Args
,
bool
enable
=
detail
::
is_output_iterator
<
OutputIt
,
char_t
<
S
>
>::
value
&&
detail
::
is_string
<
S
>::
value
>
inline
auto
format_to
(
OutputIt
out
,
const
text_style
&
ts
,
const
S
&
format_str
,
Args
&&
...
args
)
->
typename
std
::
enable_if
<
enable
,
OutputIt
>::
type
{
return
vformat_to
(
out
,
ts
,
to_string_view
(
format_str
),
fmt
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...));
}
FMT_END_NAMESPACE
...
...
include/spdlog/fmt/bundled/compile.h
View file @
2b81c40b
...
...
@@ -368,7 +368,8 @@ template <typename... Args> struct type_list {};
// Returns a reference to the argument at index N from [first, rest...].
template
<
int
N
,
typename
T
,
typename
...
Args
>
constexpr
const
auto
&
get
(
const
T
&
first
,
const
Args
&
...
rest
)
{
constexpr
const
auto
&
get
([[
maybe_unused
]]
const
T
&
first
,
[[
maybe_unused
]]
const
Args
&
...
rest
)
{
static_assert
(
N
<
1
+
sizeof
...(
Args
),
"index is out of bounds"
);
if
constexpr
(
N
==
0
)
return
first
;
...
...
@@ -406,6 +407,19 @@ constexpr text<Char> make_text(basic_string_view<Char> s, size_t pos,
return
{{
&
s
[
pos
],
size
}};
}
template
<
typename
Char
>
struct
code_unit
{
Char
value
;
using
char_type
=
Char
;
template
<
typename
OutputIt
,
typename
...
Args
>
OutputIt
format
(
OutputIt
out
,
const
Args
&
...)
const
{
return
write
<
Char
>
(
out
,
value
);
}
};
template
<
typename
Char
>
struct
is_compiled_format
<
code_unit
<
Char
>>
:
std
::
true_type
{};
// A replacement field that refers to argument N.
template
<
typename
Char
,
typename
T
,
int
N
>
struct
field
{
using
char_type
=
Char
;
...
...
@@ -430,7 +444,9 @@ template <typename Char, typename T, int N> struct spec_field {
OutputIt
format
(
OutputIt
out
,
const
Args
&
...
args
)
const
{
// This ensures that the argument type is convertile to `const T&`.
const
T
&
arg
=
get
<
N
>
(
args
...);
basic_format_context
<
OutputIt
,
Char
>
ctx
(
out
,
{});
const
auto
&
vargs
=
make_format_args
<
basic_format_context
<
OutputIt
,
Char
>>
(
args
...);
basic_format_context
<
OutputIt
,
Char
>
ctx
(
out
,
vargs
);
return
fmt
.
format
(
arg
,
ctx
);
}
};
...
...
@@ -489,16 +505,17 @@ constexpr auto parse_tail(T head, S format_str) {
template
<
typename
T
,
typename
Char
>
struct
parse_specs_result
{
formatter
<
T
,
Char
>
fmt
;
size_t
end
;
int
next_arg_id
;
};
template
<
typename
T
,
typename
Char
>
constexpr
parse_specs_result
<
T
,
Char
>
parse_specs
(
basic_string_view
<
Char
>
str
,
size_t
pos
)
{
size_t
pos
,
int
arg_id
)
{
str
.
remove_prefix
(
pos
);
auto
ctx
=
basic_format_parse_context
<
Char
>
(
str
);
auto
ctx
=
basic_format_parse_context
<
Char
>
(
str
,
{},
arg_id
+
1
);
auto
f
=
formatter
<
T
,
Char
>
();
auto
end
=
f
.
parse
(
ctx
);
return
{
f
,
pos
+
(
end
-
str
.
data
())
+
1
};
return
{
f
,
pos
+
(
end
-
str
.
data
())
+
1
,
ctx
.
next_arg_id
()
};
}
// Compiles a non-empty format string and returns the compiled representation
...
...
@@ -518,8 +535,8 @@ constexpr auto compile_format_string(S format_str) {
format_str
);
}
else
if
constexpr
(
str
[
POS
+
1
]
==
':'
)
{
using
type
=
get_type
<
ID
,
Args
>
;
constexpr
auto
result
=
parse_specs
<
type
>
(
str
,
POS
+
2
);
return
parse_tail
<
Args
,
result
.
end
,
ID
+
1
>
(
constexpr
auto
result
=
parse_specs
<
type
>
(
str
,
POS
+
2
,
ID
);
return
parse_tail
<
Args
,
result
.
end
,
result
.
next_arg_id
>
(
spec_field
<
char_type
,
type
,
ID
>
{
result
.
fmt
},
format_str
);
}
else
{
return
unknown_format
();
...
...
@@ -530,8 +547,13 @@ constexpr auto compile_format_string(S format_str) {
return
parse_tail
<
Args
,
POS
+
2
,
ID
>
(
make_text
(
str
,
POS
,
1
),
format_str
);
}
else
{
constexpr
auto
end
=
parse_text
(
str
,
POS
+
1
);
if
constexpr
(
end
-
POS
>
1
)
{
return
parse_tail
<
Args
,
end
,
ID
>
(
make_text
(
str
,
POS
,
end
-
POS
),
format_str
);
}
else
{
return
parse_tail
<
Args
,
end
,
ID
>
(
code_unit
<
char_type
>
{
str
[
POS
]},
format_str
);
}
}
}
...
...
@@ -587,8 +609,7 @@ template <typename CompiledFormat, typename... Args,
FMT_INLINE
std
::
basic_string
<
Char
>
format
(
const
CompiledFormat
&
cf
,
const
Args
&
...
args
)
{
basic_memory_buffer
<
Char
>
buffer
;
detail
::
buffer
<
Char
>&
base
=
buffer
;
cf
.
format
(
std
::
back_inserter
(
base
),
args
...);
cf
.
format
(
detail
::
buffer_appender
<
Char
>
(
buffer
),
args
...);
return
to_string
(
buffer
);
}
...
...
@@ -608,8 +629,7 @@ template <typename CompiledFormat, typename... Args,
std
::
basic_string
<
Char
>
format
(
const
CompiledFormat
&
cf
,
const
Args
&
...
args
)
{
basic_memory_buffer
<
Char
>
buffer
;
using
context
=
buffer_context
<
Char
>
;
detail
::
buffer
<
Char
>&
base
=
buffer
;
detail
::
cf
::
vformat_to
<
context
>
(
std
::
back_inserter
(
base
),
cf
,
detail
::
cf
::
vformat_to
<
context
>
(
detail
::
buffer_appender
<
Char
>
(
buffer
),
cf
,
make_format_args
<
context
>
(
args
...));
return
to_string
(
buffer
);
}
...
...
@@ -618,9 +638,13 @@ template <typename S, typename... Args,
FMT_ENABLE_IF
(
detail
::
is_compiled_string
<
S
>
::
value
)
>
FMT_INLINE
std
::
basic_string
<
typename
S
::
char_type
>
format
(
const
S
&
,
Args
&&
...
args
)
{
#ifdef __cpp_if_constexpr
if
constexpr
(
std
::
is_same
<
typename
S
::
char_type
,
char
>::
value
)
{
constexpr
basic_string_view
<
typename
S
::
char_type
>
str
=
S
();
if
(
str
.
size
()
==
2
&&
str
[
0
]
==
'{'
&&
str
[
1
]
==
'}'
)
return
fmt
::
to_string
(
detail
::
first
(
args
...));
}
#endif
constexpr
auto
compiled
=
detail
::
compile
<
Args
...
>
(
S
());
return
format
(
compiled
,
std
::
forward
<
Args
>
(
args
)...);
}
...
...
@@ -643,18 +667,30 @@ OutputIt format_to(OutputIt out, const S&, const Args&... args) {
return
format_to
(
out
,
compiled
,
args
...);
}
template
<
typename
OutputIt
,
typename
CompiledFormat
,
typename
...
Args
,
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
>
::
value
&&
std
::
is_base_of
<
detail
::
basic_compiled_format
,
CompiledFormat
>::
value
)
>
format_to_n_result
<
OutputIt
>
format_to_n
(
OutputIt
out
,
size_t
n
,
const
CompiledFormat
&
cf
,
const
Args
&
...
args
)
{
template
<
typename
OutputIt
,
typename
CompiledFormat
,
typename
...
Args
>
auto
format_to_n
(
OutputIt
out
,
size_t
n
,
const
CompiledFormat
&
cf
,
const
Args
&
...
args
)
->
typename
std
::
enable_if
<
detail
::
is_output_iterator
<
OutputIt
,
typename
CompiledFormat
::
char_type
>::
value
&&
std
::
is_base_of
<
detail
::
basic_compiled_format
,
CompiledFormat
>::
value
,
format_to_n_result
<
OutputIt
>>::
type
{
auto
it
=
format_to
(
detail
::
truncating_iterator
<
OutputIt
>
(
out
,
n
),
cf
,
args
...);
return
{
it
.
base
(),
it
.
count
()};
}
template
<
typename
OutputIt
,
typename
S
,
typename
...
Args
,
FMT_ENABLE_IF
(
detail
::
is_compiled_string
<
S
>
::
value
)
>
format_to_n_result
<
OutputIt
>
format_to_n
(
OutputIt
out
,
size_t
n
,
const
S
&
,
const
Args
&
...
args
)
{
constexpr
auto
compiled
=
detail
::
compile
<
Args
...
>
(
S
());
auto
it
=
format_to
(
detail
::
truncating_iterator
<
OutputIt
>
(
out
,
n
),
compiled
,
args
...);
return
{
it
.
base
(),
it
.
count
()};
}
template
<
typename
CompiledFormat
,
typename
...
Args
>
size_t
formatted_size
(
const
CompiledFormat
&
cf
,
const
Args
&
...
args
)
{
return
format_to
(
detail
::
counting_iterator
(),
cf
,
args
...).
count
();
...
...
include/spdlog/fmt/bundled/core.h
View file @
2b81c40b
This diff is collapsed.
Click to expand it.
include/spdlog/fmt/bundled/format-inl.h
View file @
2b81c40b
This diff is collapsed.
Click to expand it.
include/spdlog/fmt/bundled/format.h
View file @
2b81c40b
This diff is collapsed.
Click to expand it.
include/spdlog/fmt/bundled/locale.h
View file @
2b81c40b
...
...
@@ -15,22 +15,12 @@
FMT_BEGIN_NAMESPACE
namespace
detail
{
template
<
typename
Char
>
typename
buffer_context
<
Char
>::
iterator
vformat_to
(
const
std
::
locale
&
loc
,
buffer
<
Char
>&
buf
,
basic_string_view
<
Char
>
format_str
,
basic_format_args
<
buffer_context
<
type_identity_t
<
Char
>>>
args
)
{
using
af
=
arg_formatter
<
typename
buffer_context
<
Char
>::
iterator
,
Char
>
;
return
vformat_to
<
af
>
(
std
::
back_inserter
(
buf
),
to_string_view
(
format_str
),
args
,
detail
::
locale_ref
(
loc
));
}
template
<
typename
Char
>
std
::
basic_string
<
Char
>
vformat
(
const
std
::
locale
&
loc
,
basic_string_view
<
Char
>
format_str
,
basic_format_args
<
buffer_context
<
type_identity_t
<
Char
>>>
args
)
{
basic_memory_buffer
<
Char
>
buffer
;
detail
::
vformat_to
(
loc
,
buffer
,
format_str
,
args
);
detail
::
vformat_to
(
buffer
,
format_str
,
args
,
detail
::
locale_ref
(
loc
)
);
return
fmt
::
to_string
(
buffer
);
}
}
// namespace detail
...
...
@@ -45,32 +35,28 @@ inline std::basic_string<Char> vformat(
template
<
typename
S
,
typename
...
Args
,
typename
Char
=
char_t
<
S
>
>
inline
std
::
basic_string
<
Char
>
format
(
const
std
::
locale
&
loc
,
const
S
&
format_str
,
Args
&&
...
args
)
{
return
detail
::
vformat
(
loc
,
to_string_view
(
format_str
),
detail
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...));
return
detail
::
vformat
(
loc
,
to_string_view
(
format_str
),
fmt
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...));
}
template
<
typename
S
,
typename
OutputIt
,
typename
...
Args
,
typename
Char
=
enable_if_t
<
detail
::
is_output_iterator
<
OutputIt
>
::
value
,
char_t
<
S
>>
>
typename
Char
=
char_t
<
S
>,
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
,
Char
>::
value
)
>
inline
OutputIt
vformat_to
(
OutputIt
out
,
const
std
::
locale
&
loc
,
const
S
&
format_str
,
format_args_t
<
type_identity_t
<
OutputIt
>
,
Char
>
args
)
{
using
af
=
detail
::
arg_formatter
<
OutputIt
,
Char
>
;
return
vformat_to
<
af
>
(
out
,
to_string_view
(
format_str
),
args
,
detail
::
locale_ref
(
loc
)
);
basic_format_args
<
buffer_context
<
type_identity_t
<
Char
>>
>
args
)
{
decltype
(
detail
::
get_buffer
<
Char
>
(
out
))
buf
(
detail
::
get_buffer_init
(
out
))
;
vformat_to
(
buf
,
to_string_view
(
format_str
),
args
,
detail
::
locale_ref
(
loc
));
return
detail
::
get_iterator
(
buf
);
}
template
<
typename
OutputIt
,
typename
S
,
typename
...
Args
,
FMT_ENABLE_IF
(
detail
::
is_output_iterator
<
OutputIt
>
::
value
&&
detail
::
is_string
<
S
>::
value
)
>
inline
OutputIt
format_to
(
OutputIt
out
,
const
std
::
locale
&
loc
,
const
S
&
format_str
,
Args
&&
...
args
)
{
detail
::
check_format_string
<
Args
...
>
(
format_str
);
using
context
=
format_context_t
<
OutputIt
,
char_t
<
S
>>
;
format_arg_store
<
context
,
Args
...
>
as
{
args
...};
return
vformat_to
(
out
,
loc
,
to_string_view
(
format_str
),
basic_format_args
<
context
>
(
as
));
bool
enable
=
detail
::
is_output_iterator
<
OutputIt
,
char_t
<
S
>
>::
value
>
inline
auto
format_to
(
OutputIt
out
,
const
std
::
locale
&
loc
,
const
S
&
format_str
,
Args
&&
...
args
)
->
typename
std
::
enable_if
<
enable
,
OutputIt
>::
type
{
const
auto
&
vargs
=
fmt
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...);
return
vformat_to
(
out
,
loc
,
to_string_view
(
format_str
),
vargs
);
}
FMT_END_NAMESPACE
...
...
include/spdlog/fmt/bundled/os.h
View file @
2b81c40b
This diff is collapsed.
Click to expand it.
include/spdlog/fmt/bundled/ostream.h
View file @
2b81c40b
...
...
@@ -49,17 +49,27 @@ template <class Char> class formatbuf : public std::basic_streambuf<Char> {
}
};
struct
converter
{
template
<
typename
T
,
FMT_ENABLE_IF
(
is_integral
<
T
>
::
value
)
>
converter
(
T
);
};
template
<
typename
Char
>
struct
test_stream
:
std
::
basic_ostream
<
Char
>
{
private:
// Hide all operator<< from std::basic_ostream<Char>.
void_t
<>
operator
<<
(
null
<>
);
void_t
<>
operator
<<
(
const
Char
*
);
template
<
typename
T
,
FMT_ENABLE_IF
(
std
::
is_convertible
<
T
,
int
>
::
value
&&
!
std
::
is_enum
<
T
>::
value
)
>
void_t
<>
operator
<<
(
T
);
void_t
<>
operator
<<
(
converter
);
};
// Hide insertion operators for built-in types.
template
<
typename
Char
,
typename
Traits
>
void_t
<>
operator
<<
(
std
::
basic_ostream
<
Char
,
Traits
>&
,
Char
);
template
<
typename
Char
,
typename
Traits
>
void_t
<>
operator
<<
(
std
::
basic_ostream
<
Char
,
Traits
>&
,
char
);
template
<
typename
Traits
>
void_t
<>
operator
<<
(
std
::
basic_ostream
<
char
,
Traits
>&
,
char
);
template
<
typename
Traits
>
void_t
<>
operator
<<
(
std
::
basic_ostream
<
char
,
Traits
>&
,
signed
char
);
template
<
typename
Traits
>
void_t
<>
operator
<<
(
std
::
basic_ostream
<
char
,
Traits
>&
,
unsigned
char
);
// Checks if T has a user-defined operator<< (e.g. not a member of
// std::ostream).
template
<
typename
T
,
typename
Char
>
class
is_streamable
{
...
...
@@ -103,7 +113,7 @@ void format_value(buffer<Char>& buf, const T& value,
#endif
output
<<
value
;
output
.
exceptions
(
std
::
ios_base
::
failbit
|
std
::
ios_base
::
badbit
);
buf
.
resize
(
buf
.
size
());
buf
.
try_
resize
(
buf
.
size
());
}
// Formats an object of type T that has an overloaded ostream operator<<.
...
...
@@ -160,7 +170,7 @@ template <typename S, typename... Args,
typename
Char
=
enable_if_t
<
detail
::
is_string
<
S
>
::
value
,
char_t
<
S
>>>
void
print
(
std
::
basic_ostream
<
Char
>&
os
,
const
S
&
format_str
,
Args
&&
...
args
)
{
vprint
(
os
,
to_string_view
(
format_str
),
detail
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...));
fmt
::
make_args_checked
<
Args
...
>
(
format_str
,
args
...));
}
FMT_END_NAMESPACE
...
...
include/spdlog/fmt/bundled/printf.h
View file @
2b81c40b
...
...
@@ -181,7 +181,7 @@ template <typename Char> class printf_width_handler {
template
<
typename
Char
,
typename
Context
>
void
vprintf
(
buffer
<
Char
>&
buf
,
basic_string_view
<
Char
>
format
,
basic_format_args
<
Context
>
args
)
{
Context
(
std
::
back_inserter
(
buf
),
format
,
args
).
format
();
Context
(
buffer_appender
<
Char
>
(
buf
),
format
,
args
).
format
();
}
}
// namespace detail
...
...
@@ -598,7 +598,7 @@ OutputIt basic_printf_context<OutputIt, Char>::format() {
template
<
typename
Char
>
using
basic_printf_context_t
=
basic_printf_context
<
std
::
back_insert_iterator
<
detail
::
buffer
<
Char
>
>
,
Char
>
;
basic_printf_context
<
detail
::
buffer_appender
<
Char
>
,
Char
>
;
using
printf_context
=
basic_printf_context_t
<
char
>
;
using
wprintf_context
=
basic_printf_context_t
<
wchar_t
>
;
...
...
include/spdlog/fmt/bundled/ranges.h
View file @
2b81c40b
...
...
@@ -157,6 +157,9 @@ template <class Tuple, class F> void for_each(Tuple&& tup, F&& f) {
for_each
(
indexes
,
std
::
forward
<
Tuple
>
(
tup
),
std
::
forward
<
F
>
(
f
));
}
template
<
typename
Range
>
using
value_type
=
remove_cvref_t
<
decltype
(
*
std
::
declval
<
Range
>
().
begin
())
>
;
template
<
typename
Arg
,
FMT_ENABLE_IF
(
!
is_like_std_string
<
typename
std
::
decay
<
Arg
>
::
type
>::
value
)
>
FMT_CONSTEXPR
const
char
*
format_str_quoted
(
bool
add_space
,
const
Arg
&
)
{
...
...
@@ -182,7 +185,6 @@ FMT_CONSTEXPR const char* format_str_quoted(bool add_space, const char) {
FMT_CONSTEXPR
const
wchar_t
*
format_str_quoted
(
bool
add_space
,
const
wchar_t
)
{
return
add_space
?
L" '{}'"
:
L"'{}'"
;
}
}
// namespace detail
template
<
typename
T
>
struct
is_tuple_like
{
...
...
@@ -246,9 +248,18 @@ template <typename T, typename Char> struct is_range {
!
std
::
is_constructible
<
detail
::
std_string_view
<
Char
>
,
T
>::
value
;
};
template
<
typename
RangeT
,
typename
Char
>
struct
formatter
<
RangeT
,
Char
,
enable_if_t
<
fmt
::
is_range
<
RangeT
,
Char
>::
value
>>
{
template
<
typename
T
,
typename
Char
>
struct
formatter
<
T
,
Char
,
enable_if_t
<
fmt
::
is_range
<
T
,
Char
>::
value
// Workaround a bug in MSVC 2017 and earlier.
#if !FMT_MSC_VER || FMT_MSC_VER >= 1927
&&
(
has_formatter
<
detail
::
value_type
<
T
>
,
format_context
>::
value
||
detail
::
has_fallback_formatter
<
detail
::
value_type
<
T
>
,
format_context
>::
value
)
#endif
>>
{
formatting_range
<
Char
>
formatting
;
template
<
typename
ParseContext
>
...
...
@@ -257,8 +268,7 @@ struct formatter<RangeT, Char,
}
template
<
typename
FormatContext
>
typename
FormatContext
::
iterator
format
(
const
RangeT
&
values
,
FormatContext
&
ctx
)
{
typename
FormatContext
::
iterator
format
(
const
T
&
values
,
FormatContext
&
ctx
)
{
auto
out
=
detail
::
copy
(
formatting
.
prefix
,
ctx
.
out
());
size_t
i
=
0
;
auto
it
=
values
.
begin
();
...
...
src/fmt.cpp
View file @
2b81c40b
This diff is collapsed.
Click to expand it.
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