boostorg / gil

Boost.GIL - Generic Image Library | Requires C++14 since Boost 1.80
https://boostorg.github.io/gil
Boost Software License 1.0
178 stars 163 forks source link

refactor: Make packed_pixel trivially copyable and assignable #679

Closed marco-langer closed 2 years ago

marco-langer commented 2 years ago

Description

Following the Rule of Zero, this PR removes the user-defined copy constructor and copy assignment operator from packed_pixel. The type is now trivially copyable and trivially assignable:

#include <boost/gil.hpp>
#include <boost/mp11.hpp>
#include <type_traits>

namespace gil = boost::gil;
namespace mp11 = boost::mp11;

int main()
{
  using packed_channel_references_3 = typename gil::detail::packed_channel_references_vector_type
  <
      std::uint8_t,
      mp11::mp_list_c<int, 3>
  >::type;

  using packed_pixel_gray3 = gil::packed_pixel
  <
      std::uint8_t,
      packed_channel_references_3,
      gil::gray_layout_t
  >;

  static_assert(std::is_trivially_copyable<packed_pixel_gray3>::value);
  static_assert(std::is_trivially_assignable<packed_pixel_gray3, packed_pixel_gray3>::value);

  return 0;
}

Tasklist