Skip to content

Commit 5379063

Browse files
seanmvitaut
authored andcommitted
Fixed clang -Wreserved-identifier warings
Created FMT_UNCHECKED_TYPE that resolves to special identifier _Unchecked_type for Microsoft, but to a dummy string otherwise. Using _Unchecked_type is invalid because underscore + uppercase is a reserved identifier.
1 parent b591fc8 commit 5379063

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

include/fmt/compile.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ template <typename OutputIt> class truncating_iterator_base {
3636
using difference_type = std::ptrdiff_t;
3737
using pointer = void;
3838
using reference = void;
39-
using _Unchecked_type =
40-
truncating_iterator_base; // Mark iterator as checked.
39+
FMT_UNCHECKED_ITERATOR(truncating_iterator_base);
4140

4241
OutputIt base() const { return out_; }
4342
size_t count() const { return count_; }

include/fmt/core.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,13 @@
217217
# endif
218218
#endif
219219

220+
#ifdef _MSC_VER
221+
# define FMT_UNCHECKED_ITERATOR(It) \
222+
using _Unchecked_type = It // Mark iterator as checked.
223+
#else
224+
# define FMT_UNCHECKED_ITERATOR(It) using DummyTypeName = It
225+
#endif
226+
220227
#ifndef FMT_BEGIN_NAMESPACE
221228
# define FMT_BEGIN_NAMESPACE \
222229
namespace fmt { \
@@ -1498,7 +1505,7 @@ class appender : public std::back_insert_iterator<detail::buffer<char>> {
14981505
public:
14991506
using std::back_insert_iterator<detail::buffer<char>>::back_insert_iterator;
15001507
appender(base it) noexcept : base(it) {}
1501-
using _Unchecked_type = appender; // Mark iterator as checked.
1508+
FMT_UNCHECKED_ITERATOR(appender);
15021509

15031510
auto operator++() noexcept -> appender& { return *this; }
15041511

include/fmt/format.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1968,7 +1968,7 @@ class counting_iterator {
19681968
using difference_type = std::ptrdiff_t;
19691969
using pointer = void;
19701970
using reference = void;
1971-
using _Unchecked_type = counting_iterator; // Mark iterator as checked.
1971+
FMT_UNCHECKED_ITERATOR(counting_iterator);
19721972

19731973
struct value_type {
19741974
template <typename T> void operator=(const T&) {}

0 commit comments

Comments
 (0)