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
0c06c81d
Commit
0c06c81d
authored
Jul 03, 2022
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deprecated implicit conversion of enums to ints for consistency with scoped enums
parent
c12b4c0c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
23 additions
and
19 deletions
+23
-19
include/fmt/core.h
include/fmt/core.h
+16
-2
include/fmt/format.h
include/fmt/format.h
+0
-14
test/format-test.cc
test/format-test.cc
+3
-3
test/ostream-test.cc
test/ostream-test.cc
+1
-0
test/printf-test.cc
test/printf-test.cc
+1
-0
test/ranges-test.cc
test/ranges-test.cc
+1
-0
test/xchar-test.cc
test/xchar-test.cc
+1
-0
No files found.
include/fmt/core.h
View file @
0c06c81d
...
...
@@ -140,6 +140,20 @@
# endif
#endif
#ifndef FMT_DEPRECATED
# if FMT_HAS_CPP14_ATTRIBUTE(deprecated) || FMT_MSC_VERSION >= 1900
# define FMT_DEPRECATED [[deprecated]]
# else
# if (defined(__GNUC__) && !defined(__LCC__)) || defined(__clang__)
# define FMT_DEPRECATED __attribute__((deprecated))
# elif FMT_MSC_VERSION
# define FMT_DEPRECATED __declspec(deprecated)
# else
# define FMT_DEPRECATED
/* deprecated */
# endif
# endif
#endif
// [[noreturn]] is disabled on MSVC and NVCC because of bogus unreachable code
// warnings.
#if FMT_EXCEPTIONS && FMT_HAS_CPP_ATTRIBUTE(noreturn) && !FMT_MSC_VERSION && \
...
...
@@ -1420,9 +1434,9 @@ template <typename Context> struct arg_mapper {
template
<
typename
T
,
FMT_ENABLE_IF
(
std
::
is_enum
<
T
>
::
value
&&
std
::
is_convertible
<
T
,
int
>::
value
&&
!
has_formatter
<
T
,
Context
>::
value
&&
!
has_format
_as
<
T
>::
value
&&
!
has_format
ter
<
T
,
Context
>::
value
&&
!
has_fallback_formatter
<
T
,
char_type
>::
value
)
>
FMT_CONSTEXPR
FMT_INLINE
auto
map
(
const
T
&
val
)
FMT_
DEPRECATED
FMT_
CONSTEXPR
FMT_INLINE
auto
map
(
const
T
&
val
)
->
decltype
(
std
::
declval
<
arg_mapper
>
().
map
(
static_cast
<
underlying_t
<
T
>>
(
val
)))
{
return
map
(
static_cast
<
underlying_t
<
T
>>
(
val
));
...
...
include/fmt/format.h
View file @
0c06c81d
...
...
@@ -118,20 +118,6 @@ FMT_END_NAMESPACE
# endif
#endif
#ifndef FMT_DEPRECATED
# if FMT_HAS_CPP14_ATTRIBUTE(deprecated) || FMT_MSC_VERSION >= 1900
# define FMT_DEPRECATED [[deprecated]]
# else
# if (defined(__GNUC__) && !defined(__LCC__)) || defined(__clang__)
# define FMT_DEPRECATED __attribute__((deprecated))
# elif FMT_MSC_VERSION
# define FMT_DEPRECATED __declspec(deprecated)
# else
# define FMT_DEPRECATED
/* deprecated */
# endif
# endif
#endif
#ifndef FMT_USE_USER_DEFINED_LITERALS
// EDG based compilers (Intel, NVIDIA, Elbrus, etc), GCC and MSVC support UDLs.
# if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION >= 407 || \
...
...
test/format-test.cc
View file @
0c06c81d
...
...
@@ -1756,6 +1756,7 @@ TEST(format_test, group_digits_view) {
}
enum
test_enum
{
foo
,
bar
};
auto
format_as
(
test_enum
e
)
->
int
{
return
e
;
}
TEST
(
format_test
,
join
)
{
using
fmt
::
join
;
...
...
@@ -1902,6 +1903,7 @@ TEST(format_test, formatter_not_specialized) {
#if FMT_HAS_FEATURE(cxx_strong_enums)
enum
big_enum
:
unsigned
long
long
{
big_enum_value
=
5000000000ULL
};
auto
format_as
(
big_enum
e
)
->
unsigned
long
long
{
return
e
;
}
TEST
(
format_test
,
strong_enum
)
{
EXPECT_EQ
(
"5000000000"
,
fmt
::
format
(
"{}"
,
big_enum_value
));
...
...
@@ -1983,9 +1985,7 @@ TEST(format_test, to_string) {
EXPECT_EQ
(
fmt
::
to_string
(
reinterpret_cast
<
void
*>
(
0x1234
)),
"0x1234"
);
EXPECT_EQ
(
fmt
::
to_string
(
adl_test
::
fmt
::
detail
::
foo
()),
"foo"
);
EXPECT_EQ
(
fmt
::
to_string
(
convertible_to_int
()),
"42"
);
enum
foo
:
unsigned
char
{
zero
};
EXPECT_EQ
(
fmt
::
to_string
(
zero
),
"0"
);
EXPECT_EQ
(
fmt
::
to_string
(
foo
),
"0"
);
#if FMT_USE_FLOAT128
EXPECT_EQ
(
fmt
::
to_string
(
__float128
(
0.5
)),
"0.5"
);
...
...
test/ostream-test.cc
View file @
0c06c81d
...
...
@@ -54,6 +54,7 @@ auto operator<<(std::ostream& os, streamable_enum) -> std::ostream& {
}
enum
unstreamable_enum
{};
auto
format_as
(
unstreamable_enum
e
)
->
int
{
return
e
;
}
struct
empty_test
{};
auto
operator
<<
(
std
::
ostream
&
os
,
empty_test
)
->
std
::
ostream
&
{
...
...
test/printf-test.cc
View file @
0c06c81d
...
...
@@ -504,6 +504,7 @@ TEST(printf_test, pointer) {
}
enum
test_enum
{
answer
=
42
};
auto
format_as
(
test_enum
e
)
->
int
{
return
e
;
}
TEST
(
printf_test
,
enum
)
{
EXPECT_PRINTF
(
"42"
,
"%d"
,
answer
);
...
...
test/ranges-test.cc
View file @
0c06c81d
...
...
@@ -224,6 +224,7 @@ TEST(ranges_test, range) {
}
enum
test_enum
{
foo
};
auto
format_as
(
test_enum
e
)
->
int
{
return
e
;
}
TEST
(
ranges_test
,
enum_range
)
{
auto
v
=
std
::
vector
<
test_enum
>
{
test_enum
::
foo
};
...
...
test/xchar-test.cc
View file @
0c06c81d
...
...
@@ -222,6 +222,7 @@ struct formatter<streamable_enum, wchar_t> : basic_ostream_formatter<wchar_t> {
}
// namespace fmt
enum
unstreamable_enum
{};
auto
format_as
(
unstreamable_enum
e
)
->
int
{
return
e
;
}
TEST
(
xchar_test
,
enum
)
{
EXPECT_EQ
(
L"streamable_enum"
,
fmt
::
format
(
L"{}"
,
streamable_enum
()));
...
...
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