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
fd62fba9
Commit
fd62fba9
authored
Dec 09, 2021
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't convert scoped enums to integers
parent
c652f824
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
1 deletion
+15
-1
include/fmt/core.h
include/fmt/core.h
+10
-0
include/fmt/format.h
include/fmt/format.h
+1
-0
test/core-test.cc
test/core-test.cc
+3
-0
test/ranges-test.cc
test/ranges-test.cc
+1
-1
No files found.
include/fmt/core.h
View file @
fd62fba9
...
...
@@ -8,6 +8,7 @@
#ifndef FMT_CORE_H_
#define FMT_CORE_H_
#include <cstddef> // std::byte
#include <cstdio> // std::FILE
#include <cstring>
#include <iterator>
...
...
@@ -367,6 +368,12 @@ FMT_NORETURN FMT_API void assert_fail(const char* file, int line,
# endif
#endif
#ifdef __cpp_lib_byte
using
byte
=
std
::
byte
;
#else
enum
class
byte
:
unsigned
char
{};
#endif
#if defined(FMT_USE_STRING_VIEW)
template
<
typename
Char
>
using
std_string_view
=
std
::
basic_string_view
<
Char
>
;
#elif defined(FMT_USE_EXPERIMENTAL_STRING_VIEW)
...
...
@@ -1403,6 +1410,9 @@ template <typename Context> struct arg_mapper {
template
<
typename
T
,
FMT_ENABLE_IF
(
std
::
is_enum
<
T
>
::
value
&&
(
std
::
is_convertible
<
T
,
int
>::
value
||
std
::
is_same
<
T
,
detail
::
byte
>::
value
)
&&
!
has_formatter
<
T
,
Context
>::
value
&&
!
has_fallback_formatter
<
T
,
char_type
>::
value
)
>
FMT_CONSTEXPR
FMT_INLINE
auto
map
(
const
T
&
val
)
...
...
include/fmt/format.h
View file @
fd62fba9
...
...
@@ -2606,6 +2606,7 @@ FMT_FORMAT_AS(unsigned long, unsigned long long);
FMT_FORMAT_AS
(
Char
*
,
const
Char
*
);
FMT_FORMAT_AS
(
std
::
basic_string
<
Char
>
,
basic_string_view
<
Char
>
);
FMT_FORMAT_AS
(
std
::
nullptr_t
,
const
void
*
);
FMT_FORMAT_AS
(
detail
::
byte
,
unsigned
char
);
FMT_FORMAT_AS
(
detail
::
std_string_view
<
Char
>
,
basic_string_view
<
Char
>
);
template
<
typename
Char
>
...
...
test/core-test.cc
View file @
fd62fba9
...
...
@@ -737,6 +737,8 @@ struct convertible_to_pointer {
operator
const
int
*
()
const
{
return
nullptr
;
}
};
enum
class
test_scoped_enum
{};
TEST
(
core_test
,
is_formattable
)
{
static_assert
(
fmt
::
is_formattable
<
signed
char
*>::
value
,
""
);
static_assert
(
fmt
::
is_formattable
<
unsigned
char
*>::
value
,
""
);
...
...
@@ -777,6 +779,7 @@ TEST(core_test, is_formattable) {
static_assert
(
!
fmt
::
is_formattable
<
int
(
s
::*
)
>::
value
,
""
);
static_assert
(
!
fmt
::
is_formattable
<
int
(
s
::*
)()
>::
value
,
""
);
static_assert
(
!
fmt
::
is_formattable
<
test_scoped_enum
>::
value
,
""
);
}
TEST
(
core_test
,
format
)
{
EXPECT_EQ
(
fmt
::
format
(
"{}"
,
42
),
"42"
);
}
...
...
test/ranges-test.cc
View file @
fd62fba9
...
...
@@ -190,7 +190,7 @@ TEST(ranges_test, range) {
EXPECT_EQ
(
fmt
::
format
(
"{}"
,
z
),
"[0, 0, 0]"
);
}
enum
class
test_enum
{
foo
};
enum
test_enum
{
foo
};
TEST
(
ranges_test
,
enum_range
)
{
auto
v
=
std
::
vector
<
test_enum
>
{
test_enum
::
foo
};
...
...
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