Boost GIL


channel.hpp
1 //
2 // Copyright 2005-2007 Adobe Systems Incorporated
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 #ifndef BOOST_GIL_CHANNEL_HPP
9 #define BOOST_GIL_CHANNEL_HPP
10 
11 #include <boost/gil/utilities.hpp>
12 
13 #include <boost/assert.hpp>
14 #include <boost/config.hpp>
15 #include <boost/config/pragma_message.hpp>
16 #include <boost/integer/integer_mask.hpp>
17 
18 #include <cstdint>
19 #include <limits>
20 #include <type_traits>
21 
22 #ifdef BOOST_GIL_DOXYGEN_ONLY
30 #define BOOST_GIL_CONFIG_HAS_UNALIGNED_ACCESS
31 #endif
32 
33 #ifdef BOOST_GIL_CONFIG_HAS_UNALIGNED_ACCESS
34 #if defined(sun) || defined(__sun) || \ // SunOS
35  defined(__osf__) || defined(__osf) || \ // Tru64
36  defined(_hpux) || defined(hpux) || \ // HP-UX
37  defined(__arm__) || defined(__ARM_ARCH) || \ // ARM
38  defined(_AIX) // AIX
39 #error Unaligned access strictly disabled for some UNIX platforms or ARM architecture
40 #elif defined(__i386__) || defined(__x86_64__) || defined(__vax__)
41  // The check for little-endian architectures that tolerate unaligned memory
42  // accesses is just an optimization. Nothing will break if it fails to detect
43  // a suitable architecture.
44  //
45  // Unfortunately, this optimization may be a C/C++ strict aliasing rules violation
46  // if accessed data buffer has effective type that cannot be aliased
47  // without leading to undefined behaviour.
48 BOOST_PRAGMA_MESSAGE("CAUTION: Unaligned access tolerated on little-endian may cause undefined behaviour")
49 #else
50 #error Unaligned access disabled for unknown platforms and architectures
51 #endif
52 #endif // defined(BOOST_GIL_CONFIG_HAS_UNALIGNED_ACCESS)
53 
54 namespace boost { namespace gil {
55 
70 
71 namespace detail {
72 
73 template <typename T, bool IsClass>
74 struct channel_traits_impl;
75 
76 // channel traits for custom class
77 template <typename T>
78 struct channel_traits_impl<T, true>
79 {
80  using value_type = typename T::value_type;
81  using reference = typename T::reference;
82  using pointer = typename T::pointer;
83  using const_reference = typename T::const_reference;
84  using const_pointer = typename T::const_pointer;
85  static constexpr bool is_mutable = T::is_mutable;
86  static value_type min_value() { return T::min_value(); }
87  static value_type max_value() { return T::max_value(); }
88 };
89 
90 // channel traits implementation for built-in integral or floating point channel type
91 template <typename T>
92 struct channel_traits_impl<T, false>
93 {
94  using value_type = T;
95  using reference = T&;
96  using pointer = T*;
97  using const_reference = T const&;
98  using const_pointer = T const*;
99  static constexpr bool is_mutable = true;
100  static value_type min_value() { return (std::numeric_limits<T>::min)(); }
101  static value_type max_value() { return (std::numeric_limits<T>::max)(); }
102 };
103 
104 // channel traits implementation for constant built-in scalar or floating point type
105 template <typename T>
106 struct channel_traits_impl<T const, false> : channel_traits_impl<T, false>
107 {
108  using reference = T const&;
109  using pointer = T const*;
110  static constexpr bool is_mutable = false;
111 };
112 
113 } // namespace detail
114 
133 template <typename T>
134 struct channel_traits : detail::channel_traits_impl<T, std::is_class<T>::value> {};
135 
136 // Channel traits for C++ reference type - remove the reference
137 template <typename T>
138 struct channel_traits<T&> : channel_traits<T> {};
139 
140 // Channel traits for constant C++ reference type
141 template <typename T>
142 struct channel_traits<T const&> : channel_traits<T>
143 {
144  using reference = typename channel_traits<T>::const_reference;
145  using pointer = typename channel_traits<T>::const_pointer;
146  static constexpr bool is_mutable = false;
147 };
148 
152 
170 
176 template <typename BaseChannelValue, typename MinVal, typename MaxVal>
177 struct scoped_channel_value
178 {
179  using value_type = scoped_channel_value<BaseChannelValue, MinVal, MaxVal>;
180  using reference = value_type&;
181  using pointer = value_type*;
182  using const_reference = value_type const&;
183  using const_pointer = value_type const*;
184  static constexpr bool is_mutable = channel_traits<BaseChannelValue>::is_mutable;
185 
186  using base_channel_t = BaseChannelValue;
187 
188  static value_type min_value() { return MinVal::apply(); }
189  static value_type max_value() { return MaxVal::apply(); }
190 
191  scoped_channel_value() = default;
192  scoped_channel_value(scoped_channel_value const& other) : value_(other.value_) {}
193  scoped_channel_value& operator=(scoped_channel_value const& other) = default;
194  scoped_channel_value(BaseChannelValue value) : value_(value) {}
195  scoped_channel_value& operator=(BaseChannelValue value)
196  {
197  value_ = value;
198  return *this;
199  }
200 
201  auto operator++() -> scoped_channel_value& { ++value_; return *this; }
202  auto operator--() -> scoped_channel_value& { --value_; return *this; }
203 
204  auto operator++(int) -> scoped_channel_value
205  {
206  scoped_channel_value tmp=*this;
207  this->operator++(); return tmp;
208  }
209 
210  auto operator--(int) -> scoped_channel_value
211  {
212  scoped_channel_value tmp=*this;
213  this->operator--(); return tmp;
214  }
215 
216  template <typename Scalar2>
217  auto operator+=(Scalar2 v) -> scoped_channel_value& { value_+=v; return *this; }
218 
219  template <typename Scalar2>
220  auto operator-=(Scalar2 v) -> scoped_channel_value& { value_-=v; return *this; }
221 
222  template <typename Scalar2>
223  auto operator*=(Scalar2 v) -> scoped_channel_value& { value_*=v; return *this; }
224 
225  template <typename Scalar2>
226  auto operator/=(Scalar2 v) -> scoped_channel_value& { value_/=v; return *this; }
227 
228  operator BaseChannelValue() const { return value_; }
229 private:
230  BaseChannelValue value_{};
231 };
232 
233 template <typename T>
234 struct float_point_zero
235 {
236  static constexpr T apply() { return 0.0f; }
237 };
238 
239 template <typename T>
240 struct float_point_one
241 {
242  static constexpr T apply() { return 1.0f; }
243 };
244 
248 
249 // It is necessary for packed channels to have their own value type. They cannot simply use an integral large enough to store the data. Here is why:
250 // - Any operation that requires returning the result by value will otherwise return the built-in integral type, which will have incorrect range
251 // That means that after getting the value of the channel we cannot properly do channel_convert, channel_invert, etc.
252 // - Two channels are declared compatible if they have the same value type. That means that a packed channel is incorrectly declared compatible with an integral type
253 namespace detail {
254 
255 // returns the smallest fast unsigned integral type that has at least NumBits bits
256 template <int NumBits>
257 struct min_fast_uint :
258  std::conditional
259  <
260  NumBits <= 8,
261  std::uint_least8_t,
262  typename std::conditional
263  <
264  NumBits <= 16,
265  std::uint_least16_t,
266  typename std::conditional
267  <
268  NumBits <= 32,
269  std::uint_least32_t,
270  std::uintmax_t
271  >::type
272  >::type
273  >
274 {};
275 
276 template <int NumBits>
277 struct num_value_fn
278  : std::conditional<NumBits < 32, std::uint32_t, std::uint64_t>
279 {};
280 
281 template <int NumBits>
282 struct max_value_fn
283  : std::conditional<NumBits <= 32, std::uint32_t, std::uint64_t>
284 {};
285 
286 } // namespace detail
287 
301 
304 template <int NumBits>
305 class packed_channel_value
306 {
307 public:
308  using integer_t = typename detail::min_fast_uint<NumBits>::type;
309 
310  using value_type = packed_channel_value<NumBits>;
311  using reference = value_type&;
312  using const_reference = value_type const&;
313  using pointer = value_type*;
314  using const_pointer = value_type const*;
315  static constexpr bool is_mutable = true;
316 
317  static value_type min_value() { return 0; }
318  static value_type max_value() { return low_bits_mask_t< NumBits >::sig_bits; }
319 
320  packed_channel_value() = default;
321  packed_channel_value(integer_t v)
322  {
323  value_ = static_cast<integer_t>(v & low_bits_mask_t<NumBits>::sig_bits_fast);
324  }
325 
326  template <typename Scalar>
327  packed_channel_value(Scalar v)
328  {
329  value_ = packed_channel_value(static_cast<integer_t>(v));
330  }
331 
332  static auto num_bits() -> unsigned int { return NumBits; }
333 
334  operator integer_t() const { return value_; }
335 
336 private:
337  integer_t value_{};
338 };
339 
340 namespace detail {
341 
342 template <std::size_t K>
343 struct static_copy_bytes
344 {
345  void operator()(unsigned char const* from, unsigned char* to) const
346  {
347  *to = *from;
348  static_copy_bytes<K - 1>()(++from, ++to);
349  }
350 };
351 
352 template <>
353 struct static_copy_bytes<0>
354 {
355  void operator()(unsigned char const*, unsigned char*) const {}
356 };
357 
358 template <typename Derived, typename BitField, int NumBits, bool IsMutable>
359 class packed_channel_reference_base
360 {
361 protected:
362  using data_ptr_t = typename std::conditional<IsMutable, void*, void const*>::type;
363 public:
364  data_ptr_t _data_ptr; // void* pointer to the first byte of the bit range
365 
366  using value_type = packed_channel_value<NumBits>;
367  using reference = Derived const;
368  using pointer = value_type*;
369  using const_pointer = value_type const*;
370  static constexpr int num_bits = NumBits;
371  static constexpr bool is_mutable = IsMutable;
372 
373  static auto min_value() -> value_type { return channel_traits<value_type>::min_value(); }
374  static auto max_value() -> value_type { return channel_traits<value_type>::max_value(); }
375 
376  using bitfield_t = BitField;
377  using integer_t = typename value_type::integer_t;
378 
379  packed_channel_reference_base(data_ptr_t data_ptr) : _data_ptr(data_ptr) {}
380  packed_channel_reference_base(packed_channel_reference_base const& ref) : _data_ptr(ref._data_ptr) {}
381 
382  auto operator=(integer_t v) const -> Derived const& { set(v); return derived(); }
383 
384  auto operator++() const -> Derived const& { set(get()+1); return derived(); }
385  auto operator--() const -> Derived const& { set(get()-1); return derived(); }
386 
387  auto operator++(int) const -> Derived
388  {
389  Derived tmp=derived();
390  this->operator++(); return tmp;
391  }
392 
393  auto operator--(int) const -> Derived
394  {
395  Derived tmp=derived();
396  this->operator--();
397  return tmp;
398  }
399 
400  template <typename Scalar2>
401  auto operator+=(Scalar2 v) const -> Derived const&
402  {
403  set( static_cast<integer_t>( get() + v ));
404  return derived();
405  }
406 
407  template <typename Scalar2>
408  auto operator-=(Scalar2 v) const -> Derived const&
409  {
410  set( static_cast<integer_t>( get() - v )); return derived();
411  }
412 
413  template <typename Scalar2>
414  auto operator*=(Scalar2 v) const -> Derived const&
415  {
416  set( static_cast<integer_t>( get() * v ));
417  return derived();
418  }
419 
420  template <typename Scalar2>
421  auto operator/=(Scalar2 v) const -> Derived const&
422  {
423  set( static_cast<integer_t>( get() / v ));
424  return derived();
425  }
426 
427  operator integer_t() const { return get(); }
428  auto operator&() const -> data_ptr_t {return _data_ptr;}
429 
430 protected:
431 
432  using num_value_t = typename detail::num_value_fn<NumBits>::type;
433  using max_value_t = typename detail::max_value_fn<NumBits>::type;
434 
435  static const num_value_t num_values = static_cast< num_value_t >( 1 ) << NumBits ;
436  static const max_value_t max_val = static_cast< max_value_t >( num_values - 1 );
437 
438 #if defined(BOOST_GIL_CONFIG_HAS_UNALIGNED_ACCESS)
439  const bitfield_t& get_data() const { return *static_cast<const bitfield_t*>(_data_ptr); }
440  void set_data(const bitfield_t& val) const { *static_cast< bitfield_t*>(_data_ptr) = val; }
441 #else
442  auto get_data() const -> bitfield_t
443  {
444  bitfield_t ret;
445  static_copy_bytes<sizeof(bitfield_t) >()(gil_reinterpret_cast_c<const unsigned char*>(_data_ptr),gil_reinterpret_cast<unsigned char*>(&ret));
446  return ret;
447  }
448 
449  void set_data(bitfield_t const& val) const
450  {
451  static_copy_bytes<sizeof(bitfield_t) >()(gil_reinterpret_cast_c<const unsigned char*>(&val),gil_reinterpret_cast<unsigned char*>(_data_ptr));
452  }
453 #endif
454 
455 private:
456  void set(integer_t value) const { // can this be done faster??
457  this->derived().set_unsafe(((value % num_values) + num_values) % num_values);
458  }
459  auto get() const -> integer_t { return derived().get(); }
460  auto derived() const -> Derived const& { return static_cast<const Derived&>(*this); }
461 };
462 } // namespace detail
463 
477 
481 template <typename BitField, int FirstBit, int NumBits, bool IsMutable>
482 class packed_channel_reference;
483 
487 template <typename BitField, int NumBits, bool IsMutable>
488 class packed_dynamic_channel_reference;
489 
492 template <typename BitField, int FirstBit, int NumBits>
493 class packed_channel_reference<BitField, FirstBit, NumBits, false>
494  : public detail::packed_channel_reference_base
495  <
496  packed_channel_reference<BitField, FirstBit, NumBits, false>,
497  BitField,
498  NumBits,
499  false
500  >
501 {
502  using parent_t = detail::packed_channel_reference_base
503  <
504  packed_channel_reference<BitField, FirstBit, NumBits, false>,
505  BitField,
506  NumBits,
507  false
508  >;
509 
510  friend class packed_channel_reference<BitField, FirstBit, NumBits, true>;
511 
512  static const BitField channel_mask = static_cast<BitField>(parent_t::max_val) << FirstBit;
513 
514  void operator=(packed_channel_reference const&);
515 public:
516  using const_reference = packed_channel_reference<BitField,FirstBit,NumBits,false> const;
517  using mutable_reference = packed_channel_reference<BitField,FirstBit,NumBits,true> const;
518  using integer_t = typename parent_t::integer_t;
519 
520  explicit packed_channel_reference(const void* data_ptr) : parent_t(data_ptr) {}
521  packed_channel_reference(const packed_channel_reference& ref) : parent_t(ref._data_ptr) {}
522  packed_channel_reference(const mutable_reference& ref) : parent_t(ref._data_ptr) {}
523 
524  auto first_bit() const -> unsigned int { return FirstBit; }
525 
526  auto get() const -> integer_t { return integer_t((this->get_data()&channel_mask) >> FirstBit); }
527 };
528 
531 template <typename BitField, int FirstBit, int NumBits>
532 class packed_channel_reference<BitField,FirstBit,NumBits,true>
533  : public detail::packed_channel_reference_base<packed_channel_reference<BitField,FirstBit,NumBits,true>,BitField,NumBits,true>
534 {
535  using parent_t = detail::packed_channel_reference_base<packed_channel_reference<BitField,FirstBit,NumBits,true>,BitField,NumBits,true>;
536  friend class packed_channel_reference<BitField,FirstBit,NumBits,false>;
537 
538  static const BitField channel_mask = static_cast< BitField >( parent_t::max_val ) << FirstBit;
539 
540 public:
541  using const_reference = packed_channel_reference<BitField,FirstBit,NumBits,false> const;
542  using mutable_reference = packed_channel_reference<BitField,FirstBit,NumBits,true> const;
543  using integer_t = typename parent_t::integer_t;
544 
545  explicit packed_channel_reference(void* data_ptr) : parent_t(data_ptr) {}
546  packed_channel_reference(const packed_channel_reference& ref) : parent_t(ref._data_ptr) {}
547 
548  packed_channel_reference const& operator=(integer_t value) const
549  {
550  BOOST_ASSERT(value <= parent_t::max_val);
551  set_unsafe(value);
552  return *this;
553  }
554 
555  auto operator=(mutable_reference const& ref) const -> packed_channel_reference const& { set_from_reference(ref.get_data()); return *this; }
556  auto operator=(const_reference const& ref) const -> packed_channel_reference const& { set_from_reference(ref.get_data()); return *this; }
557 
558  template <bool Mutable1>
559  auto operator=(packed_dynamic_channel_reference<BitField,NumBits,Mutable1> const& ref) const -> packed_channel_reference const& { set_unsafe(ref.get()); return *this; }
560 
561  auto first_bit() const -> unsigned int { return FirstBit; }
562 
563  auto get() const -> integer_t { return integer_t((this->get_data()&channel_mask) >> FirstBit); }
564  void set_unsafe(integer_t value) const { this->set_data((this->get_data() & ~channel_mask) | (( static_cast< BitField >( value )<<FirstBit))); }
565 
566 private:
567  void set_from_reference(const BitField& other_bits) const { this->set_data((this->get_data() & ~channel_mask) | (other_bits & channel_mask)); }
568 };
569 
570 }} // namespace boost::gil
571 
572 namespace std {
573 // We are forced to define swap inside std namespace because on some platforms (Visual Studio 8) STL calls swap qualified.
574 // swap with 'left bias':
575 // - swap between proxy and anything
576 // - swap between value type and proxy
577 // - swap between proxy and proxy
578 
581 template <typename BF, int FB, int NB, bool M, typename R>
582 inline
583 void swap(boost::gil::packed_channel_reference<BF, FB, NB, M> const x, R& y)
584 {
585  boost::gil::swap_proxy
586  <
587  typename boost::gil::packed_channel_reference<BF, FB, NB, M>::value_type
588  >(x, y);
589 }
590 
591 
594 template <typename BF, int FB, int NB, bool M>
595 inline
596 void swap(
597  typename boost::gil::packed_channel_reference<BF, FB, NB, M>::value_type& x,
598  boost::gil::packed_channel_reference<BF, FB, NB, M> const y)
599 {
600  boost::gil::swap_proxy
601  <
602  typename boost::gil::packed_channel_reference<BF, FB, NB, M>::value_type
603  >(x,y);
604 }
605 
608 template <typename BF, int FB, int NB, bool M> inline
609 void swap(
610  boost::gil::packed_channel_reference<BF, FB, NB, M> const x,
611  boost::gil::packed_channel_reference<BF, FB, NB, M> const y)
612 {
613  boost::gil::swap_proxy
614  <
615  typename boost::gil::packed_channel_reference<BF, FB, NB, M>::value_type
616  >(x,y);
617 }
618 
619 } // namespace std
620 
621 namespace boost { namespace gil {
622 
637 
641 template <typename BitField, int NumBits>
642 class packed_dynamic_channel_reference<BitField,NumBits,false>
643  : public detail::packed_channel_reference_base<packed_dynamic_channel_reference<BitField,NumBits,false>,BitField,NumBits,false>
644 {
645  using parent_t = detail::packed_channel_reference_base<packed_dynamic_channel_reference<BitField,NumBits,false>,BitField,NumBits,false>;
646  friend class packed_dynamic_channel_reference<BitField,NumBits,true>;
647 
648  unsigned _first_bit; // 0..7
649 
650  void operator=(const packed_dynamic_channel_reference&);
651 public:
652  using const_reference = packed_dynamic_channel_reference<BitField,NumBits,false> const;
653  using mutable_reference = packed_dynamic_channel_reference<BitField,NumBits,true> const;
654  using integer_t = typename parent_t::integer_t;
655 
656  packed_dynamic_channel_reference(void const* data_ptr, unsigned first_bit) : parent_t(data_ptr), _first_bit(first_bit) {}
657  packed_dynamic_channel_reference(const_reference const& ref) : parent_t(ref._data_ptr), _first_bit(ref._first_bit) {}
658  packed_dynamic_channel_reference(mutable_reference const& ref) : parent_t(ref._data_ptr), _first_bit(ref._first_bit) {}
659 
660  auto first_bit() const -> unsigned int { return _first_bit; }
661 
662  auto get() const -> integer_t
663  {
664  const BitField channel_mask = static_cast< integer_t >( parent_t::max_val ) <<_first_bit;
665  return static_cast< integer_t >(( this->get_data()&channel_mask ) >> _first_bit );
666  }
667 };
668 
672 template <typename BitField, int NumBits>
673 class packed_dynamic_channel_reference<BitField,NumBits,true>
674  : public detail::packed_channel_reference_base<packed_dynamic_channel_reference<BitField,NumBits,true>,BitField,NumBits,true>
675 {
676  using parent_t = detail::packed_channel_reference_base<packed_dynamic_channel_reference<BitField,NumBits,true>,BitField,NumBits,true>;
677  friend class packed_dynamic_channel_reference<BitField,NumBits,false>;
678 
679  unsigned _first_bit;
680 
681 public:
682  using const_reference = packed_dynamic_channel_reference<BitField,NumBits,false> const;
683  using mutable_reference = packed_dynamic_channel_reference<BitField,NumBits,true> const;
684  using integer_t = typename parent_t::integer_t;
685 
686  packed_dynamic_channel_reference(void* data_ptr, unsigned first_bit) : parent_t(data_ptr), _first_bit(first_bit) {}
687  packed_dynamic_channel_reference(packed_dynamic_channel_reference const& ref) : parent_t(ref._data_ptr), _first_bit(ref._first_bit) {}
688 
689  auto operator=(integer_t value) const -> packed_dynamic_channel_reference const&
690  {
691  BOOST_ASSERT(value <= parent_t::max_val);
692  set_unsafe(value);
693  return *this;
694  }
695 
696  auto operator=(mutable_reference const& ref) const -> packed_dynamic_channel_reference const& { set_unsafe(ref.get()); return *this; }
697  auto operator=(const_reference const& ref) const -> packed_dynamic_channel_reference const& { set_unsafe(ref.get()); return *this; }
698 
699  template <typename BitField1, int FirstBit1, bool Mutable1>
700  auto operator=(packed_channel_reference<BitField1, FirstBit1, NumBits, Mutable1> const& ref) const -> packed_dynamic_channel_reference const&
701  {
702  set_unsafe(ref.get());
703  return *this;
704  }
705 
706  auto first_bit() const -> unsigned int { return _first_bit; }
707 
708  auto get() const -> integer_t
709  {
710  BitField const channel_mask = static_cast< integer_t >( parent_t::max_val ) << _first_bit;
711  return static_cast< integer_t >(( this->get_data()&channel_mask ) >> _first_bit );
712  }
713 
714  void set_unsafe(integer_t value) const {
715  const BitField channel_mask = static_cast< integer_t >( parent_t::max_val ) << _first_bit;
716  this->set_data((this->get_data() & ~channel_mask) | value<<_first_bit);
717  }
718 };
719 } } // namespace boost::gil
720 
721 namespace std {
722 // We are forced to define swap inside std namespace because on some platforms (Visual Studio 8) STL calls swap qualified.
723 // swap with 'left bias':
724 // - swap between proxy and anything
725 // - swap between value type and proxy
726 // - swap between proxy and proxy
727 
728 
731 template <typename BF, int NB, bool M, typename R> inline
732 void swap(const boost::gil::packed_dynamic_channel_reference<BF,NB,M> x, R& y) {
733  boost::gil::swap_proxy<typename boost::gil::packed_dynamic_channel_reference<BF,NB,M>::value_type>(x,y);
734 }
735 
736 
739 template <typename BF, int NB, bool M> inline
740 void swap(typename boost::gil::packed_dynamic_channel_reference<BF,NB,M>::value_type& x, const boost::gil::packed_dynamic_channel_reference<BF,NB,M> y) {
741  boost::gil::swap_proxy<typename boost::gil::packed_dynamic_channel_reference<BF,NB,M>::value_type>(x,y);
742 }
743 
746 template <typename BF, int NB, bool M> inline
747 void swap(const boost::gil::packed_dynamic_channel_reference<BF,NB,M> x, const boost::gil::packed_dynamic_channel_reference<BF,NB,M> y) {
748  boost::gil::swap_proxy<typename boost::gil::packed_dynamic_channel_reference<BF,NB,M>::value_type>(x,y);
749 }
750 } // namespace std
751 
752 // \brief Determines the fundamental type which may be used, e.g., to cast from larger to smaller channel types.
753 namespace boost { namespace gil {
754 template <typename T>
755 struct base_channel_type_impl { using type = T; };
756 
757 template <int N>
758 struct base_channel_type_impl<packed_channel_value<N> >
759 { using type = typename packed_channel_value<N>::integer_t; };
760 
761 template <typename B, int F, int N, bool M>
762 struct base_channel_type_impl<packed_channel_reference<B, F, N, M> >
763 {
764  using type = typename packed_channel_reference<B,F,N,M>::integer_t;
765 };
766 
767 template <typename B, int N, bool M>
768 struct base_channel_type_impl<packed_dynamic_channel_reference<B, N, M> >
769 {
770  using type = typename packed_dynamic_channel_reference<B,N,M>::integer_t;
771 };
772 
773 template <typename ChannelValue, typename MinV, typename MaxV>
774 struct base_channel_type_impl<scoped_channel_value<ChannelValue, MinV, MaxV> >
775 { using type = ChannelValue; };
776 
777 template <typename T>
778 struct base_channel_type : base_channel_type_impl<typename std::remove_cv<T>::type> {};
779 
780 }} //namespace boost::gil
781 
782 #endif
Models a constant subbyte channel reference whose bit offset is a runtime parameter....
Definition: channel.hpp:644
Models a mutable subbyte channel reference whose bit offset is a runtime parameter....
Definition: channel.hpp:675
void swap(const boost::gil::packed_dynamic_channel_reference< BF, NB, M > x, const boost::gil::packed_dynamic_channel_reference< BF, NB, M > y)
swap for packed_dynamic_channel_reference
Definition: channel.hpp:747
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36