remove template parameter from Counter
This commit is contained in:
parent
ab86531dc5
commit
4073ac22fc
|
@ -54,7 +54,7 @@ auto CountWins(std::vector<Card>& cards) -> std::vector<std::size_t>
|
|||
std::set_intersection(
|
||||
card.mine .begin(), card.mine .end(),
|
||||
card.winners.begin(), card.winners.end(),
|
||||
Counter<std::size_t>{});
|
||||
Counter{});
|
||||
result.push_back(counter);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,20 +3,20 @@
|
|||
#include <cstdint>
|
||||
#include <iterator>
|
||||
|
||||
template <typename T>
|
||||
/// @brief Output iterator that only counts the number of outputs.
|
||||
struct Counter
|
||||
{
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
struct EmptyRef {
|
||||
auto operator=(T const&) const -> void {}
|
||||
auto operator=(T && ) const -> void {}
|
||||
template <typename T>
|
||||
auto operator=(T&&) const -> void {}
|
||||
};
|
||||
|
||||
std::size_t n;
|
||||
std::size_t n = 0;
|
||||
|
||||
Counter() : n{0} {}
|
||||
Counter(std::size_t n) : n{n} {}
|
||||
Counter() = default;
|
||||
constexpr Counter(std::size_t n) : n{n} {}
|
||||
|
||||
// prefix increment
|
||||
auto operator++() -> Counter&
|
||||
|
@ -38,7 +38,7 @@ struct Counter
|
|||
|
||||
auto operator-(Counter rhs) const -> difference_type
|
||||
{
|
||||
return difference_type{n} - difference_type{rhs};
|
||||
return static_cast<difference_type>(n) - static_cast<difference_type>(rhs);
|
||||
}
|
||||
|
||||
operator std::size_t() const
|
||||
|
@ -47,4 +47,4 @@ struct Counter
|
|||
}
|
||||
};
|
||||
|
||||
static_assert(std::output_iterator<Counter<int>, int>);
|
||||
static_assert(std::output_iterator<Counter, int>);
|
||||
|
|
Loading…
Reference in New Issue
Block a user