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
ff6e46ed
Commit
ff6e46ed
authored
Sep 22, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More cleanup
parent
715f2b4c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
44 deletions
+36
-44
include/fmt/core.h
include/fmt/core.h
+19
-33
include/fmt/format.h
include/fmt/format.h
+11
-11
test/format-impl-test.cc
test/format-impl-test.cc
+6
-0
No files found.
include/fmt/core.h
View file @
ff6e46ed
...
...
@@ -25,7 +25,7 @@
#endif
#if defined(__has_include) && !defined(__INTELLISENSE__) && \
(!defined(__INTEL_COMPILER) || __INTEL_COMPILER >=
1600)
!(defined(__INTEL_COMPILER) && __INTEL_COMPILER <
1600)
# define FMT_HAS_INCLUDE(x) __has_include(x)
#else
# define FMT_HAS_INCLUDE(x) 0
...
...
@@ -72,7 +72,7 @@
#ifndef FMT_USE_CONSTEXPR11
# define FMT_USE_CONSTEXPR11 \
(FMT_
MSC_VER >= 1900 || FMT_GCC_VERSION >= 406 || FMT_USE_CONSTEXPR
)
(FMT_
USE_CONSTEXPR || FMT_GCC_VERSION >= 406 || FMT_MSC_VER >= 1900
)
#endif
#if FMT_USE_CONSTEXPR11
# define FMT_CONSTEXPR11 constexpr
...
...
@@ -104,24 +104,15 @@
# define FMT_NULL NULL
# endif
#endif
#ifndef FMT_USE_NULLPTR
# define FMT_USE_NULLPTR 0
#endif
#if FMT_HAS_CPP_ATTRIBUTE(noreturn)
# define FMT_NORETURN [[noreturn]]
#else
# define FMT_NORETURN
#endif
// Check if exceptions are disabled.
#if defined(__GNUC__) && !defined(__EXCEPTIONS)
# define FMT_EXCEPTIONS 0
#elif FMT_MSC_VER && !_HAS_EXCEPTIONS
#if (defined(__GNUC__) && !defined(__EXCEPTIONS)) || \
FMT_MSC_VER && !_HAS_EXCEPTIONS
# define FMT_EXCEPTIONS 0
#endif
#ifndef FMT_EXCEPTIONS
#else
# define FMT_EXCEPTIONS 1
#endif
...
...
@@ -147,8 +138,7 @@
# endif
#endif
// This is needed because GCC still uses throw() in its headers when exceptions
// are disabled.
// GCC still uses throw() in its headers when exceptions are disabled.
#if FMT_GCC_VERSION
# define FMT_DTOR_NOEXCEPT FMT_DETECTED_NOEXCEPT
#else
...
...
@@ -358,11 +348,8 @@ struct formatter {
};
template
<
typename
T
,
typename
Char
,
typename
Enable
=
void
>
struct
convert_to_int
{
enum
{
value
=
!
std
::
is_arithmetic
<
T
>::
value
&&
std
::
is_convertible
<
T
,
int
>::
value
};
};
struct
convert_to_int
:
std
::
integral_constant
<
bool
,
!
std
::
is_arithmetic
<
T
>::
value
&&
std
::
is_convertible
<
T
,
int
>::
value
>
{};
namespace
internal
{
...
...
@@ -1115,13 +1102,13 @@ const long long format_arg_store<Context, Args...>::TYPES = get_types();
*/
template
<
typename
Context
,
typename
...
Args
>
inline
format_arg_store
<
Context
,
Args
...
>
make_format_args
(
const
Args
&
...
args
)
{
make_format_args
(
const
Args
&
...
args
)
{
return
format_arg_store
<
Context
,
Args
...
>
(
args
...);
}
template
<
typename
...
Args
>
inline
format_arg_store
<
format_context
,
Args
...
>
make_format_args
(
const
Args
&
...
args
)
{
make_format_args
(
const
Args
&
...
args
)
{
return
format_arg_store
<
format_context
,
Args
...
>
(
args
...);
}
...
...
@@ -1222,12 +1209,12 @@ class basic_format_args {
// It is a separate type rather than a typedef to make symbols readable.
struct
format_args
:
basic_format_args
<
format_context
>
{
template
<
typename
...
Args
>
format_args
(
Args
&&
...
arg
)
format_args
(
Args
&&
...
arg
)
:
basic_format_args
<
format_context
>
(
std
::
forward
<
Args
>
(
arg
)...)
{}
};
struct
wformat_args
:
basic_format_args
<
wformat_context
>
{
template
<
typename
...
Args
>
wformat_args
(
Args
&&
...
arg
)
wformat_args
(
Args
&&
...
arg
)
:
basic_format_args
<
wformat_context
>
(
std
::
forward
<
Args
>
(
arg
)...)
{}
};
...
...
@@ -1383,7 +1370,7 @@ template <typename Container, typename... Args>
inline
typename
std
::
enable_if
<
is_contiguous
<
Container
>::
value
,
std
::
back_insert_iterator
<
Container
>>::
type
format_to
(
std
::
back_insert_iterator
<
Container
>
out
,
string_view
format_str
,
const
Args
&
...
args
)
{
string_view
format_str
,
const
Args
&
...
args
)
{
format_arg_store
<
format_context
,
Args
...
>
as
{
args
...};
return
vformat_to
(
out
,
format_str
,
as
);
}
...
...
@@ -1392,7 +1379,7 @@ template <typename Container, typename... Args>
inline
typename
std
::
enable_if
<
is_contiguous
<
Container
>::
value
,
std
::
back_insert_iterator
<
Container
>>::
type
format_to
(
std
::
back_insert_iterator
<
Container
>
out
,
wstring_view
format_str
,
const
Args
&
...
args
)
{
wstring_view
format_str
,
const
Args
&
...
args
)
{
return
vformat_to
(
out
,
format_str
,
make_format_args
<
wformat_context
>
(
args
...));
}
...
...
@@ -1420,7 +1407,7 @@ inline std::basic_string<Char> vformat(
template
<
typename
String
,
typename
...
Args
>
inline
std
::
basic_string
<
typename
internal
::
format_string_traits
<
String
>::
char_type
>
format
(
const
String
&
format_str
,
const
Args
&
...
args
)
{
format
(
const
String
&
format_str
,
const
Args
&
...
args
)
{
internal
::
check_format_string
<
Args
...
>
(
format_str
);
// This should be just
// return vformat(format_str, make_format_args(args...));
...
...
@@ -1445,7 +1432,7 @@ FMT_API void vprint(std::FILE *f, wstring_view format_str, wformat_args args);
\endrst
*/
template
<
typename
...
Args
>
inline
void
print
(
std
::
FILE
*
f
,
string_view
format_str
,
const
Args
&
...
args
)
{
inline
void
print
(
std
::
FILE
*
f
,
string_view
format_str
,
const
Args
&
...
args
)
{
format_arg_store
<
format_context
,
Args
...
>
as
(
args
...);
vprint
(
f
,
format_str
,
as
);
}
...
...
@@ -1454,8 +1441,7 @@ inline void print(std::FILE *f, string_view format_str, const Args & ... args) {
set via ``fwide(f, 1)`` or ``_setmode(_fileno(f), _O_U8TEXT)`` on Windows.
*/
template
<
typename
...
Args
>
inline
void
print
(
std
::
FILE
*
f
,
wstring_view
format_str
,
const
Args
&
...
args
)
{
inline
void
print
(
std
::
FILE
*
f
,
wstring_view
format_str
,
const
Args
&
...
args
)
{
format_arg_store
<
wformat_context
,
Args
...
>
as
(
args
...);
vprint
(
f
,
format_str
,
as
);
}
...
...
@@ -1473,13 +1459,13 @@ FMT_API void vprint(wstring_view format_str, wformat_args args);
\endrst
*/
template
<
typename
...
Args
>
inline
void
print
(
string_view
format_str
,
const
Args
&
...
args
)
{
inline
void
print
(
string_view
format_str
,
const
Args
&
...
args
)
{
format_arg_store
<
format_context
,
Args
...
>
as
{
args
...};
vprint
(
format_str
,
as
);
}
template
<
typename
...
Args
>
inline
void
print
(
wstring_view
format_str
,
const
Args
&
...
args
)
{
inline
void
print
(
wstring_view
format_str
,
const
Args
&
...
args
)
{
format_arg_store
<
wformat_context
,
Args
...
>
as
(
args
...);
vprint
(
format_str
,
as
);
}
...
...
include/fmt/format.h
View file @
ff6e46ed
...
...
@@ -2375,7 +2375,7 @@ class system_error : public std::runtime_error {
\endrst
*/
template
<
typename
...
Args
>
system_error
(
int
error_code
,
string_view
message
,
const
Args
&
...
args
)
system_error
(
int
error_code
,
string_view
message
,
const
Args
&
...
args
)
:
std
::
runtime_error
(
""
)
{
init
(
error_code
,
message
,
make_format_args
(
args
...));
}
...
...
@@ -2663,7 +2663,7 @@ class basic_writer {
void
write_double
(
T
value
,
const
format_specs
&
spec
);
template
<
typename
T
>
void
write_double_sprintf
(
T
value
,
const
format_specs
&
spec
,
internal
::
basic_buffer
<
char_type
>
&
buffer
);
internal
::
basic_buffer
<
char_type
>
&
buffer
);
template
<
typename
Char
>
struct
str_writer
{
...
...
@@ -2924,7 +2924,7 @@ template <typename Range>
template
<
typename
T
>
void
basic_writer
<
Range
>::
write_double_sprintf
(
T
value
,
const
format_specs
&
spec
,
internal
::
basic_buffer
<
char_type
>
&
buffer
)
{
internal
::
basic_buffer
<
char_type
>
&
buffer
)
{
// Buffer capacity must be non-zero, otherwise MSVC's vsnprintf_s will fail.
FMT_ASSERT
(
buffer
.
capacity
()
!=
0
,
"empty buffer"
);
...
...
@@ -3008,7 +3008,7 @@ class windows_error : public system_error {
\endrst
*/
template
<
typename
...
Args
>
windows_error
(
int
error_code
,
string_view
message
,
const
Args
&
...
args
)
{
windows_error
(
int
error_code
,
string_view
message
,
const
Args
&
...
args
)
{
init
(
error_code
,
message
,
make_format_args
(
args
...));
}
};
...
...
@@ -3315,7 +3315,7 @@ struct format_handler : internal::error_handler {
}
iterator
on_format_specs
(
iterator
it
)
{
auto
&
parse_ctx
=
context
.
parse_context
();
auto
&
parse_ctx
=
context
.
parse_context
();
parse_ctx
.
advance_to
(
pointer_from
(
it
));
if
(
fmt
::
visit
(
internal
::
custom_formatter
<
Char
,
Context
>
(
context
),
arg
))
return
iterator
(
parse_ctx
);
...
...
@@ -3461,7 +3461,7 @@ template <
typename
Char
=
typename
internal
::
format_string_traits
<
String
>
::
char_type
>
inline
typename
buffer_context
<
Char
>::
type
::
iterator
format_to
(
basic_memory_buffer
<
Char
,
SIZE
>
&
buf
,
const
String
&
format_str
,
const
Args
&
...
args
)
{
const
Args
&
...
args
)
{
internal
::
check_format_string
<
Args
...
>
(
format_str
);
return
vformat_to
(
buf
,
basic_string_view
<
Char
>
(
format_str
),
...
...
@@ -3506,7 +3506,7 @@ inline OutputIt vformat_to(
*/
template
<
typename
OutputIt
,
typename
...
Args
>
inline
OutputIt
format_to
(
OutputIt
out
,
string_view
format_str
,
const
Args
&
...
args
)
{
const
Args
&
...
args
)
{
return
vformat_to
(
out
,
format_str
,
make_format_args
<
typename
format_context_t
<
OutputIt
>::
type
>
(
args
...));
}
...
...
@@ -3528,7 +3528,7 @@ using format_to_n_args = fmt::basic_format_args<format_to_n_context<OutputIt>>;
template
<
typename
OutputIt
,
typename
...
Args
>
inline
format_arg_store
<
format_to_n_context
<
OutputIt
>
,
Args
...
>
make_format_to_n_args
(
const
Args
&
...
args
)
{
make_format_to_n_args
(
const
Args
&
...
args
)
{
return
format_arg_store
<
format_to_n_context
<
OutputIt
>
,
Args
...
>
(
args
...);
}
...
...
@@ -3575,7 +3575,7 @@ inline std::basic_string<Char> internal::vformat(
template
<
typename
String
,
typename
...
Args
>
inline
typename
std
::
enable_if
<
internal
::
is_compile_string
<
String
>::
value
>::
type
print
(
String
format_str
,
const
Args
&
...
args
)
{
print
(
String
format_str
,
const
Args
&
...
args
)
{
internal
::
check_format_string
<
Args
...
>
(
format_str
);
return
vprint
(
format_str
.
data
(),
make_format_args
(
args
...));
}
...
...
@@ -3586,7 +3586,7 @@ inline typename std::enable_if<internal::is_compile_string<String>::value>::type
*/
template
<
typename
...
Args
>
inline
std
::
size_t
formatted_size
(
string_view
format_str
,
const
Args
&
...
args
)
{
const
Args
&
...
args
)
{
auto
it
=
format_to
(
internal
::
counting_iterator
<
char
>
(),
format_str
,
args
...);
return
it
.
count
();
}
...
...
@@ -3614,7 +3614,7 @@ struct udl_formatter {
const
Char
*
str
;
template
<
typename
...
Args
>
auto
operator
()(
Args
&&
...
args
)
const
auto
operator
()(
Args
&&
...
args
)
const
->
decltype
(
format
(
str
,
std
::
forward
<
Args
>
(
args
)...))
{
return
format
(
str
,
std
::
forward
<
Args
>
(
args
)...);
}
...
...
test/format-impl-test.cc
View file @
ff6e46ed
...
...
@@ -24,6 +24,12 @@
#undef min
#undef max
#if FMT_HAS_CPP_ATTRIBUTE(noreturn)
# define FMT_NORETURN [[noreturn]]
#else
# define FMT_NORETURN
#endif
using
fmt
::
internal
::
fp
;
template
<
bool
is_iec559
>
...
...
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