56 using const_iterator = const_pointer;
66 template<
typename Pixmap>
78 constexpr row_iterator &operator++()
noexcept { ++_y;
return *
this; }
79 constexpr row_iterator &operator++(
int)
noexcept {
auto tmp = *
this; ++_y;
return tmp; }
80 constexpr row_iterator &operator--()
noexcept { --_y;
return *
this; }
81 constexpr row_iterator &operator--(
int)
noexcept {
auto tmp = *
this; --_y;
return tmp; }
82 [[
nodiscard]]
constexpr auto operator*()
const noexcept {
return (*_ptr)[_y]; }
86 template<
typename Pixmap>
103 std::destroy(this->begin(), this->end());
104 if (_data !=
nullptr) {
120 _width(
other._width),
121 _height(
other._height),
122 _allocator(
std::allocator_traits<
allocator_type>::select_on_container_copy_construction(
other._allocator))
135 _data(std::exchange(
other._data,
nullptr)),
136 _capacity(std::exchange(
other._capacity, 0)),
137 _width(std::exchange(
other._width, 0)),
138 _height(std::exchange(
other._height, 0)),
139 _allocator(std::exchange(
other._allocator, {}))
156 if (&
other ==
this) {
160 static_assert(std::is_nothrow_copy_constructible_v<value_type>);
164 _width =
other._width;
165 _height =
other._height;
193 _width =
other._width;
194 _height =
other._height;
211 if (&
other ==
this) {
218 _data = std::exchange(
other._data,
nullptr);
219 _capacity = std::exchange(
other._capacity, 0);
220 _width = std::exchange(
other._width, 0);
221 _height = std::exchange(
other._height, 0);
222 _allocator =
other._allocator;
225 }
else if (_capacity >=
other.size()) {
228 _width =
other._width;
229 _height =
other._height;
231 std::uninitialized_move(
other.begin(),
other.end(),
this->begin());
259 _width =
other._width;
260 _height =
other._height;
274 _data(
std::allocator_traits<
allocator_type>::allocate(allocator, width * height)),
275 _capacity(width * height),
278 _allocator(allocator)
280 std::uninitialized_value_construct(begin(), end());
283 template<std::convertible_to<value_type> O>
290 _data(
std::allocator_traits<
allocator_type>::allocate(allocator, width * height)),
291 _capacity(width * height),
294 _allocator(allocator)
296 if (width == stride) {
316 std::destroy(begin(),
dst);
323 template<std::convertible_to<value_type> O>
329 pixmap(data, width, height, width, allocator)
333 template<std::convertible_to<value_type> O>
339 template<std::convertible_to<value_type> O>
345 template<std::same_as<value_type const> O>
351 [[
nodiscard]]
constexpr friend bool operator==(pixmap
const& lhs, pixmap
const& rhs)
noexcept
353 if (lhs._width != rhs._width
or lhs._height != rhs._height) {
356 return std::equal(lhs.begin(), lhs.end(), rhs.begin());
378 return _width * _height;
390 return _width == 0
and _height == 0;
420 return _data +
size();
425 return _data +
size();
430 return _data +
size();
435 hi_axiom(x < _width);
436 hi_axiom(y < _height);
437 return _data[y * _width + x];
442 hi_axiom(x < _width);
443 hi_axiom(y < _height);
444 return _data[y * _width + x];
449 hi_axiom(y < _height);
450 return {_data + y * _width, _width};
455 hi_axiom(y < height());
456 return {_data + y * _width, _width};
461 return row_range{
this};
466 return row_range{
this};
475 hilet p = _data + y * _width + x;
486 std::destroy(begin(), end());
491 constexpr void shrink_to_fit()
494 if (_data !=
nullptr) {
506 std::uninitialized_move(begin(), end(),
new_data);
512 std::destroy(begin(), end());
constexpr size_type capacity() const noexcept
The number of pixels of capacity allocated.
Definition pixmap.hpp:383
constexpr size_type size() const noexcept
The number of pixels (width * height) in this image.
Definition pixmap.hpp:376