1 // 2 // Copyright 2019 Mateusz Loskot <mateusz at loskot dot net> 3 // 4 // Distributed under the Boost Software License, Version 1.0 5 // See accompanying file LICENSE_1_0.txt or copy at 6 // http://www.boost.org/LICENSE_1_0.txt 7 // 8 #include <boost/gil.hpp> 9 #include <boost/gil/extension/numeric/kernel.hpp> 10 #include <boost/assert.hpp> 11 12 #include <initializer_list> 13 #include <type_traits> 14 15 namespace boost { namespace gil { 16 17 namespace test { namespace fixture { 18 19 template <typename T> create_kernel(std::initializer_list<T> const & values)20auto create_kernel(std::initializer_list<T> const& values) 21 -> gil::kernel_1d<T> 22 { 23 static_assert(std::is_arithmetic<T>::value, 24 "kernel value type should be integral or floating-point type"); 25 BOOST_ASSERT_MSG((values.size() - 1) % 2 == 0, "expected odd number of kernel values"); 26 gil::kernel_1d<T> kernel(values.begin(), values.size(), (values.size() - 1) / 2); 27 return kernel; 28 } 29 30 }}}} // namespace boost::gil::test::fixture 31