A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/fmtlib/fmt/commit/ba36a04811c5f73681a8e1c1e28539182e6a211b below:

Remove counting_iterator · fmtlib/fmt@ba36a04 · GitHub

File tree Expand file treeCollapse file tree 4 files changed

+8

-57

lines changed

Filter options

Expand file treeCollapse file tree 4 files changed

+8

-57

lines changed Original file line number Diff line number Diff line change

@@ -1103,7 +1103,7 @@ template <typename T = char> class counting_buffer : public buffer<T> {

1103 1103

}

1104 1104 1105 1105

public:

1106 -

counting_buffer() : buffer<T>(grow, data_, 0, buffer_size) {}

1106 +

FMT_CONSTEXPR counting_buffer() : buffer<T>(grow, data_, 0, buffer_size) {}

1107 1107 1108 1108

auto count() -> size_t { return count_ + this->size(); }

1109 1109

};

Original file line number Diff line number Diff line change

@@ -21,12 +21,6 @@ FMT_EXPORT class compiled_string {};

21 21 22 22

namespace detail {

23 23 24 -

template <typename T, typename InputIt>

25 -

FMT_CONSTEXPR inline auto copy(InputIt begin, InputIt end, counting_iterator it)

26 -

-> counting_iterator {

27 -

return it + (end - begin);

28 -

}

29 - 30 24

template <typename S>

31 25

struct is_compiled_string : std::is_base_of<compiled_string, S> {};

32 26

@@ -496,7 +490,8 @@ template <typename S, typename... Args,

496 490

FMT_ENABLE_IF(detail::is_compiled_string<S>::value)>

497 491

auto formatted_size(const S& fmt, const Args&... args) -> size_t {

498 492

auto buf = detail::counting_buffer<>();

499 -

return fmt::format_to(fmt::appender(buf), fmt, args...).count();

493 +

fmt::format_to(appender(buf), fmt, args...);

494 +

return buf.count();

500 495

}

501 496 502 497

template <typename S, typename... Args,

Original file line number Diff line number Diff line change

@@ -2235,46 +2235,6 @@ FMT_CONSTEXPR FMT_INLINE auto write(OutputIt out, T value,

2235 2235

loc);

2236 2236

}

2237 2237 2238 -

// An output iterator that counts the number of objects written to it and

2239 -

// discards them.

2240 -

class counting_iterator {

2241 -

private:

2242 -

size_t count_;

2243 - 2244 -

public:

2245 -

using iterator_category = std::output_iterator_tag;

2246 -

using difference_type = std::ptrdiff_t;

2247 -

using pointer = void;

2248 -

using reference = void;

2249 -

FMT_UNCHECKED_ITERATOR(counting_iterator);

2250 - 2251 -

struct value_type {

2252 -

template <typename T> FMT_CONSTEXPR void operator=(const T&) {}

2253 -

};

2254 - 2255 -

FMT_CONSTEXPR counting_iterator() : count_(0) {}

2256 - 2257 -

FMT_CONSTEXPR auto count() const -> size_t { return count_; }

2258 - 2259 -

FMT_CONSTEXPR auto operator++() -> counting_iterator& {

2260 -

++count_;

2261 -

return *this;

2262 -

}

2263 -

FMT_CONSTEXPR auto operator++(int) -> counting_iterator {

2264 -

auto it = *this;

2265 -

++*this;

2266 -

return it;

2267 -

}

2268 - 2269 -

FMT_CONSTEXPR friend auto operator+(counting_iterator it, difference_type n)

2270 -

-> counting_iterator {

2271 -

it.count_ += static_cast<size_t>(n);

2272 -

return it;

2273 -

}

2274 - 2275 -

FMT_CONSTEXPR auto operator*() const -> value_type { return {}; }

2276 -

};

2277 - 2278 2238

template <typename Char, typename OutputIt>

2279 2239

FMT_CONSTEXPR auto write(OutputIt out, basic_string_view<Char> s,

2280 2240

const format_specs& specs) -> OutputIt {

@@ -2285,7 +2245,11 @@ FMT_CONSTEXPR auto write(OutputIt out, basic_string_view<Char> s,

2285 2245

bool is_debug = specs.type == presentation_type::debug;

2286 2246

size_t width = 0;

2287 2247 2288 -

if (is_debug) size = write_escaped_string(counting_iterator{}, s).count();

2248 +

if (is_debug) {

2249 +

auto buf = counting_buffer<Char>();

2250 +

write_escaped_string(basic_appender<Char>(buf), s);

2251 +

size = buf.count();

2252 +

}

2289 2253 2290 2254

if (specs.width != 0) {

2291 2255

if (is_debug)

Original file line number Diff line number Diff line change

@@ -14,14 +14,6 @@

14 14

#include "gmock/gmock.h"

15 15

#include "gtest-extra.h"

16 16 17 -

TEST(iterator_test, counting_iterator) {

18 -

auto it = fmt::detail::counting_iterator();

19 -

auto prev = it++;

20 -

EXPECT_EQ(prev.count(), 0);

21 -

EXPECT_EQ(it.count(), 1);

22 -

EXPECT_EQ((it + 41).count(), 42);

23 -

}

24 - 25 17

TEST(compile_test, compile_fallback) {

26 18

// FMT_COMPILE should fallback on runtime formatting when `if constexpr` is

27 19

// not available.

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4