Skip to content

Commit f3342a6

Browse files
committed
Make PixelBuffer usable with Boost.Test iterator tests
1 parent 778ba7b commit f3342a6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

include/libsiedler2/PixelBuffer.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ class PixelBuffer
3131
{
3232
public:
3333
using PixelType = T_Pixel;
34+
using Container = std::vector<T_Pixel>;
35+
// Compatibility with Boost < 1.67
36+
using iterator = typename Container::iterator;
37+
using const_iterator = typename Container::const_iterator;
38+
using value_type = typename Container::value_type;
39+
auto size() const { return pixels_.size(); }
3440

3541
PixelBuffer() : width_(0), height_(0) {}
3642
PixelBuffer(uint16_t width, uint16_t height, T_Pixel defValue);
@@ -64,7 +70,7 @@ class PixelBuffer
6470
uint16_t width_, height_;
6571

6672
protected:
67-
std::vector<T_Pixel> pixels_;
73+
Container pixels_;
6874
};
6975

7076
template<typename T_Pixel>

tests/testBmp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ BOOST_AUTO_TEST_CASE(CreatePalettedBmp)
168168
// Fill with all colors from the palette
169169
BOOST_TEST_REQUIRE(buffer.getNumPixels() >= 256u); // Make sure we use all colors
170170
int idx = 0;
171-
for(auto& c : buffer.getPixels())
171+
for(auto& c : buffer)
172172
{
173173
c = palette->get(idx++);
174174
idx %= 256;

0 commit comments

Comments
 (0)