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
40779749
Commit
40779749
authored
Jun 07, 2019
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
is_formattable -> has_formatter
parent
b3cf8613
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
8 deletions
+10
-8
include/fmt/core.h
include/fmt/core.h
+8
-6
include/fmt/format.h
include/fmt/format.h
+1
-1
test/format-test.cc
test/format-test.cc
+1
-1
No files found.
include/fmt/core.h
View file @
40779749
...
...
@@ -492,6 +492,12 @@ struct convert_to_int : bool_constant<!std::is_arithmetic<T>::value &&
namespace
internal
{
// Specifies if T has an enabled formatter specialization. The type can be
// formattable even if it doesn't have a formatter e.g. via conversion.
template
<
typename
T
,
typename
Context
>
using
has_formatter
=
std
::
is_constructible
<
typename
Context
::
template
formatter_type
<
T
>
>
;
/** A contiguous memory buffer with an optional growing ability. */
template
<
typename
T
>
class
buffer
{
private:
...
...
@@ -675,10 +681,6 @@ template <typename Context> struct custom_value {
void
(
*
format
)(
const
void
*
arg
,
parse_context
&
parse_ctx
,
Context
&
ctx
);
};
template
<
typename
T
,
typename
Context
>
using
is_formattable
=
std
::
is_constructible
<
typename
Context
::
template
formatter_type
<
T
>
>
;
// A formatting argument value.
template
<
typename
Context
>
class
value
{
public:
...
...
@@ -727,7 +729,7 @@ template <typename Context> class value {
// have different extension points, e.g. `formatter<T>` for `format` and
// `printf_formatter<T>` for `printf`.
custom
.
format
=
&
format_custom_arg
<
T
,
conditional_t
<
is_formattable
<
T
,
Context
>::
value
,
T
,
conditional_t
<
has_formatter
<
T
,
Context
>::
value
,
typename
Context
::
template
formatter_type
<
T
>,
internal
::
fallback_formatter
<
T
,
char_type
>>>
;
}
...
...
@@ -875,7 +877,7 @@ inline init<C, const T&, custom_type> make_value(const T& val) {
template
<
typename
C
,
typename
T
,
FMT_ENABLE_IF
(
std
::
is_class
<
T
>
::
value
&&
std
::
is_convertible
<
T
,
int
>::
value
&&
is_formattable
<
T
,
C
>::
value
&&
T
,
int
>::
value
&&
has_formatter
<
T
,
C
>::
value
&&
!
std
::
is_same
<
T
,
typename
C
::
char_type
>::
value
)
>
inline
init
<
C
,
const
T
&
,
custom_type
>
make_value
(
const
T
&
val
)
{
return
val
;
...
...
include/fmt/format.h
View file @
40779749
...
...
@@ -2179,7 +2179,7 @@ FMT_CONSTEXPR const typename ParseContext::char_type* parse_format_specs(
ParseContext
&
ctx
)
{
// GCC 7.2 requires initializer.
typedef
typename
ParseContext
::
char_type
char_type
;
conditional_t
<
is_formattable
<
T
,
buffer_context
<
char_type
>>::
value
,
conditional_t
<
has_formatter
<
T
,
buffer_context
<
char_type
>>::
value
,
formatter
<
T
,
char_type
>
,
internal
::
fallback_formatter
<
T
,
char_type
>>
f
;
...
...
test/format-test.cc
View file @
40779749
...
...
@@ -1877,7 +1877,7 @@ enum TestEnum { A };
TEST
(
FormatTest
,
Enum
)
{
EXPECT_EQ
(
"0"
,
fmt
::
format
(
"{}"
,
A
));
}
TEST
(
FormatTest
,
FormatterNotSpecialized
)
{
EXPECT_FALSE
((
fmt
::
internal
::
is_formattable
<
EXPECT_FALSE
((
fmt
::
internal
::
has_formatter
<
fmt
::
formatter
<
TestEnum
>
,
fmt
::
format_context
>::
value
));
}
...
...
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