Remove truncating_iterator_default_construct_base
This commit is contained in:
parent
d8e49e9f4e
commit
e4789a2eee
@ -465,45 +465,16 @@ class counting_iterator {
|
||||
value_type operator*() const { return {}; }
|
||||
};
|
||||
|
||||
// Used to ensure that truncating_iterator SFINAEs properly on the underlying
|
||||
// iterator's default constructibility.
|
||||
template <typename OutputIt, typename = typename std::is_default_constructible<
|
||||
OutputIt>::type>
|
||||
class truncating_iterator_default_construct_base;
|
||||
|
||||
template<typename OutputIt>
|
||||
class truncating_iterator_default_construct_base<OutputIt, std::false_type> {
|
||||
template <typename OutputIt> class truncating_iterator_base {
|
||||
protected:
|
||||
OutputIt out_;
|
||||
|
||||
truncating_iterator_default_construct_base() = delete;
|
||||
|
||||
explicit truncating_iterator_default_construct_base(OutputIt out) :
|
||||
out_(std::move(out)) {}
|
||||
};
|
||||
|
||||
template<typename OutputIt>
|
||||
class truncating_iterator_default_construct_base<OutputIt, std::true_type> {
|
||||
protected:
|
||||
OutputIt out_;
|
||||
|
||||
truncating_iterator_default_construct_base() : out_() {}
|
||||
|
||||
explicit truncating_iterator_default_construct_base(OutputIt out) :
|
||||
out_(std::move(out)) {}
|
||||
};
|
||||
|
||||
template <typename OutputIt> class truncating_iterator_base
|
||||
: protected truncating_iterator_default_construct_base<OutputIt> {
|
||||
protected:
|
||||
size_t limit_ = 0;
|
||||
size_t limit_;
|
||||
size_t count_ = 0;
|
||||
|
||||
truncating_iterator_base() = default;
|
||||
truncating_iterator_base() : out_(), limit_(0) {}
|
||||
|
||||
truncating_iterator_base(OutputIt out, size_t limit)
|
||||
: truncating_iterator_default_construct_base<OutputIt>(out),
|
||||
limit_(limit), count_(0) {}
|
||||
: out_(out), limit_(limit) {}
|
||||
|
||||
public:
|
||||
using iterator_category = std::output_iterator_tag;
|
||||
@ -514,7 +485,7 @@ template <typename OutputIt> class truncating_iterator_base
|
||||
using _Unchecked_type =
|
||||
truncating_iterator_base; // Mark iterator as checked.
|
||||
|
||||
OutputIt base() const { return this->out_; }
|
||||
OutputIt base() const { return out_; }
|
||||
size_t count() const { return count_; }
|
||||
};
|
||||
|
||||
|
||||
@ -170,27 +170,6 @@ TEST(IteratorTest, TruncatingIteratorDefaultConstruct) {
|
||||
EXPECT_EQ(std::size_t{0}, it.count());
|
||||
}
|
||||
|
||||
TEST(IteratorTest, TruncatingIteratorDeletedDefaultConstruct) {
|
||||
struct non_default_constructible_iterator {
|
||||
using iterator_category = std::output_iterator_tag;
|
||||
using value_type = void;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
using pointer = void;
|
||||
using reference = void;
|
||||
|
||||
non_default_constructible_iterator() = delete;
|
||||
|
||||
non_default_constructible_iterator& operator++();
|
||||
non_default_constructible_iterator operator++(int);
|
||||
char& operator*() const;
|
||||
};
|
||||
|
||||
static_assert(
|
||||
!std::is_default_constructible<fmt::detail::truncating_iterator<
|
||||
non_default_constructible_iterator>>::value,
|
||||
"");
|
||||
}
|
||||
|
||||
#ifdef __cpp_lib_ranges
|
||||
TEST(IteratorTest, TruncatingIteratorOutputIterator) {
|
||||
static_assert(std::output_iterator<fmt::detail::truncating_iterator<char*>,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user