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.
This commit is contained in:
Sean McBride 2022-03-07 11:16:43 -05:00 committed by Victor Zverovich
parent b591fc87dc
commit 5379063b54
3 changed files with 10 additions and 4 deletions

View File

@ -36,8 +36,7 @@ template <typename OutputIt> class truncating_iterator_base {
using difference_type = std::ptrdiff_t;
using pointer = void;
using reference = void;
using _Unchecked_type =
truncating_iterator_base; // Mark iterator as checked.
FMT_UNCHECKED_ITERATOR(truncating_iterator_base);
OutputIt base() const { return out_; }
size_t count() const { return count_; }

View File

@ -217,6 +217,13 @@
# endif
#endif
#ifdef _MSC_VER
# define FMT_UNCHECKED_ITERATOR(It) \
using _Unchecked_type = It // Mark iterator as checked.
#else
# define FMT_UNCHECKED_ITERATOR(It) using DummyTypeName = It
#endif
#ifndef FMT_BEGIN_NAMESPACE
# define FMT_BEGIN_NAMESPACE \
namespace fmt { \
@ -1498,7 +1505,7 @@ class appender : public std::back_insert_iterator<detail::buffer<char>> {
public:
using std::back_insert_iterator<detail::buffer<char>>::back_insert_iterator;
appender(base it) noexcept : base(it) {}
using _Unchecked_type = appender; // Mark iterator as checked.
FMT_UNCHECKED_ITERATOR(appender);
auto operator++() noexcept -> appender& { return *this; }

View File

@ -1968,7 +1968,7 @@ class counting_iterator {
using difference_type = std::ptrdiff_t;
using pointer = void;
using reference = void;
using _Unchecked_type = counting_iterator; // Mark iterator as checked.
FMT_UNCHECKED_ITERATOR(counting_iterator);
struct value_type {
template <typename T> void operator=(const T&) {}