diff --git a/include/fmt/format.h b/include/fmt/format.h index 5679fdd8..a6b928c4 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -212,7 +212,7 @@ inline Dest bit_cast(const Source& source) { return dest; } -// An implementation of iterator_t for pre-C++20 systems. +// An approximation of iterator_t for pre-C++20 systems. template using iterator_t = decltype(std::begin(std::declval())); @@ -220,26 +220,11 @@ using iterator_t = decltype(std::begin(std::declval())); # define FMT_USE_GRISU 1 #endif -template inline bool use_grisu() { +template constexpr bool use_grisu() { return FMT_USE_GRISU && std::numeric_limits::is_iec559 && sizeof(T) <= sizeof(double); } -// A range with an iterator appending to a buffer. -template class buffer_range { - public: - using value_type = T; - using iterator = std::back_insert_iterator>; - - private: - iterator begin_; - - public: - buffer_range(buffer& buf) : begin_(std::back_inserter(buf)) {} - explicit buffer_range(iterator it) : begin_(it) {} - iterator begin() const { return begin_; } -}; - // A range with the specified output iterator and value type. template class output_range { @@ -249,9 +234,22 @@ class output_range { public: using value_type = T; using iterator = OutputIt; + struct sentinel {}; explicit output_range(OutputIt it) : it_(it) {} OutputIt begin() const { return it_; } + sentinel end() const { return {}; } // Sentinel is not used yet. +}; + +// A range with an iterator appending to a buffer. +template +class buffer_range + : public output_range>, T> { + public: + using iterator = std::back_insert_iterator>; + using output_range::output_range; + buffer_range(buffer& buf) + : output_range(std::back_inserter(buf)) {} }; #ifdef _SECURE_SCL