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

Add initializing image constructor #486

Merged
merged 4 commits into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions include/boost/gil/extension/dynamic_image/any_image.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//
// Copyright 2005-2007 Adobe Systems Incorporated
// Copyright 2020 Samuel Debionne
//
// Distributed under the Boost Software License, Version 1.0
// See accompanying file LICENSE_1_0.txt or copy at
Expand Down Expand Up @@ -100,6 +101,9 @@ class any_image : public variant2::variant<Images...>

template <typename Image>
explicit any_image(Image const& img) : parent_t(img) {}

template <typename Image>
any_image(Image&& img) : parent_t(std::move(img)) {}
sdebionne marked this conversation as resolved.
Show resolved Hide resolved

template <typename Image>
explicit any_image(Image& img, bool do_swap) : parent_t(img, do_swap) {}
Expand Down
1 change: 1 addition & 0 deletions test/extension/dynamic_image/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#
message(STATUS "Boost.GIL: Configuring tests in test/extension/dynamic_image")
foreach(_name
any_image
sdebionne marked this conversation as resolved.
Show resolved Hide resolved
subimage_view)
set(_test t_ext_dynamic_image_${_name})
set(_target test_ext_dynamic_image_${_name})
Expand Down
1 change: 1 addition & 0 deletions test/extension/dynamic_image/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ import testing ;

alias headers : [ generate_self_contained_headers extension/dynamic_image ] ;

run any_image.cpp ;
run subimage_view.cpp ;
45 changes: 45 additions & 0 deletions test/extension/dynamic_image/any_image.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Copyright 2020 Samuel Debionne
//
// 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.hpp>
#include <boost/gil/extension/dynamic_image/any_image.hpp>

#include <boost/core/lightweight_test.hpp>

#include "test_fixture.hpp"
#include "core/image/test_fixture.hpp"

namespace gil = boost::gil;
namespace fixture = boost::gil::test::fixture;

struct test_any_image_move_ctor
{
template <typename Image>
void operator()(Image const&)
{
using image_t = Image;
fixture::dynamic_image i0(fixture::create_image<image_t>(4, 4, 128));
BOOST_TEST_EQ(i0.dimensions().x, 4);
BOOST_TEST_EQ(i0.dimensions().y, 4);

fixture::dynamic_image i1 = fixture::create_image<image_t>(4, 4, 128);
BOOST_TEST_EQ(i1.dimensions().x, 4);
BOOST_TEST_EQ(i1.dimensions().y, 4);
}
static void run()
{
boost::mp11::mp_for_each<fixture::image_types>(test_any_image_move_ctor{});
}
};


int main()
{
test_any_image_move_ctor::run();

return ::boost::report_errors();
}