mirror of
https://github.com/boostorg/gil.git
synced 2026-01-29 07:32:18 +00:00
The assignment was superfluous in general case and incorrect in specific case when the algorithm was given a lambda expression. The copy assignment operator is defined as deleted for lambda expressions. Add minimal test for for_each_pixel algorithm to verify it compiles with lambda expression.
33 lines
734 B
C++
33 lines
734 B
C++
//
|
|
// Copyright 2018 Mateusz Loskot <mateusz at loskot dot net>
|
|
//
|
|
// Distributed under the Boost Software License, Version 1.0
|
|
// See accompanying file LICENSE_1_0.txt or copy at
|
|
// http://www.boost.org/LICENSE_1_0.txt
|
|
//
|
|
#include <boost/gil/algorithm.hpp>
|
|
#include <boost/gil/image.hpp>
|
|
|
|
#include <boost/core/lightweight_test.hpp>
|
|
|
|
namespace gil = boost::gil;
|
|
|
|
void test_lambda_expression()
|
|
{
|
|
gil::gray8_pixel_t const gray128(128);
|
|
gil::gray8_image_t image(2, 2, gray128);
|
|
|
|
int sum{0};
|
|
gil::for_each_pixel(gil::view(image), [&sum](gil::gray8_pixel_t& p) {
|
|
sum += gil::at_c<0>(p);
|
|
});
|
|
BOOST_TEST(sum == 2 * 2 * 128);
|
|
}
|
|
|
|
int main()
|
|
{
|
|
test_lambda_expression();
|
|
|
|
return boost::report_errors();
|
|
}
|