Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conflict with std::fill_n and boost::range::fill_n (Trac 7189) #152

Merged
merged 1 commit into from
Oct 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/boost/gil/algorithm.hpp
Original file line number Diff line number Diff line change
@@ -355,7 +355,7 @@ void fill(boost::gil::iterator_from_2d<IL> first, boost::gil::iterator_from_2d<I
std::ptrdiff_t n=last-first;
while (n>0) {
std::ptrdiff_t numToDo=std::min<const std::ptrdiff_t>(n,(std::ptrdiff_t)(first.width()-first.x_pos()));
fill_n(first.x(), numToDo, val);
std::fill_n(first.x(), numToDo, val);
first+=numToDo;
n-=numToDo;
}
1 change: 1 addition & 0 deletions test/Jamfile
Original file line number Diff line number Diff line change
@@ -71,6 +71,7 @@ run image.cpp sample_image.cpp error_if.cpp : : gil_reference_checksums.txt ;
run channel.cpp error_if.cpp ;
run pixel.cpp error_if.cpp ;
run pixel_iterator.cpp error_if.cpp ;
build-project algorithm ;
build-project channel ;
build-project image_view ;

1 change: 1 addition & 0 deletions test/algorithm/Jamfile
Original file line number Diff line number Diff line change
@@ -15,3 +15,4 @@ project
;

run for_each_pixel.cpp ;
run std_fill.cpp ;
37 changes: 37 additions & 0 deletions test/algorithm/std_fill.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// 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/gil/image_view.hpp>

#include <boost/array.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/range/algorithm/fill_n.hpp>

#include <array>
#include <cstdint>

namespace gil = boost::gil;

template <typename ArrayPixel>
void test_array_as_range()
{
static_assert(ArrayPixel().size() == 2, "two-element array expected");

gil::image<ArrayPixel> img(1, 1);
std::fill(gil::view(img).begin(), gil::view(img).end(), ArrayPixel{0, 1});
BOOST_TEST(*gil::view(img).at(0,0) == (ArrayPixel{0, 1}));
}

int main()
{
test_array_as_range<boost::array<int, 2>>();
test_array_as_range<std::array<int, 2>>();

return boost::report_errors();
}