mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Conform std::iterator_traits<fmt::appender>
to [iterator.traits]/1 (#4185)
* Conform `std::iterator_traits<fmt::appender>` to [iterator.traits]/1
> In addition, the types
> ```c++
> iterator_traits<I>::pointer
> iterator_traits<I>::reference
> ```
> shall be defined as the iterator’s pointer and reference types; that is, for an iterator object `a` of class type, the same type as `decltype(a.operator->())` and `decltype(*a)`, respectively. The type `iterator_traits<I>::pointer` shall be void for an iterator of class type `I` that does not support `operator->`. Additionally, in the case of an output iterator, the types
> ```c++
> iterator_traits<I>::value_type
> iterator_traits<I>::difference_type
> iterator_traits<I>::reference
> ```
> may be defined as `void`.
* Remove unnecessary member types from basic_appender
This reverts commit 1accf6c0a0
.
* Address clang-format issue
This commit is contained in:
@ -2382,11 +2382,6 @@ template <typename T> class basic_appender {
|
|||||||
detail::buffer<T>* container;
|
detail::buffer<T>* container;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using iterator_category = int;
|
|
||||||
using value_type = T;
|
|
||||||
using pointer = T*;
|
|
||||||
using reference = T&;
|
|
||||||
using difference_type = decltype(pointer() - pointer());
|
|
||||||
using container_type = detail::buffer<T>;
|
using container_type = detail::buffer<T>;
|
||||||
|
|
||||||
FMT_CONSTEXPR basic_appender(detail::buffer<T>& buf) : container(&buf) {}
|
FMT_CONSTEXPR basic_appender(detail::buffer<T>& buf) : container(&buf) {}
|
||||||
|
@ -119,11 +119,13 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
template <> struct iterator_traits<fmt::appender> {
|
template <class T> struct iterator_traits<fmt::basic_appender<T>> {
|
||||||
using iterator_category = output_iterator_tag;
|
using iterator_category = output_iterator_tag;
|
||||||
using value_type = char;
|
using value_type = T;
|
||||||
using reference = char&;
|
using difference_type =
|
||||||
using difference_type = fmt::appender::difference_type;
|
decltype(static_cast<int*>(nullptr) - static_cast<int*>(nullptr));
|
||||||
|
using pointer = void;
|
||||||
|
using reference = void;
|
||||||
};
|
};
|
||||||
} // namespace std
|
} // namespace std
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user