8 #ifndef BOOST_GIL_CONCEPTS_HPP
9 #define BOOST_GIL_CONCEPTS_HPP
11 #include <boost/config.hpp>
12 #include <boost/concept_check.hpp>
13 #include <boost/core/ignore_unused.hpp>
14 #include <boost/iterator/iterator_concepts.hpp>
15 #include <boost/mpl/and.hpp>
16 #include <boost/mpl/size.hpp>
17 #include <boost/type_traits.hpp>
18 #include <boost/utility/enable_if.hpp>
24 namespace boost {
namespace gil {
26 #if defined(__GNUC__) && (__GNUC__ >= 4)
27 #pragma GCC diagnostic push
28 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
31 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
33 #pragma warning(disable:4510) //default constructor could not be generated
34 #pragma warning(disable:4512) //assignment operator could not be generated
35 #pragma warning(disable:4610) //can never be instantiated - user defined constructor required
38 template <
typename T>
struct channel_traits;
39 template <
typename P>
struct is_pixel;
40 template <
typename dstT,
typename srcT>
41 typename channel_traits<dstT>::value_type
channel_convert(
const srcT& val);
42 template <
typename T>
class point;
43 template <std::
size_t K,
typename T>
const T& axis_value(
point<T> const& p);
44 template <std::
size_t K,
typename T> T& axis_value(
point<T>& p);
45 template <
typename ColorBase,
int K>
struct kth_element_type;
46 template <
typename ColorBase,
int K>
struct kth_element_reference_type;
47 template <
typename ColorBase,
int K>
struct kth_element_const_reference_type;
50 template <
typename ColorBase>
struct size;
53 template <
typename T>
struct color_space_type;
54 template <
typename T>
struct channel_mapping_type;
55 template <
typename T>
struct is_planar;
66 namespace detail {
template <
typename Element,
typename Layout,
int K>
struct homogeneous_color_base; }
67 template <
int K,
typename E,
typename L,
int N>
68 typename add_reference<E>::type
at_c( detail::homogeneous_color_base<E,L,N>& p);
70 template <
int K,
typename E,
typename L,
int N>
71 typename add_reference<typename add_const<E>::type>::type
at_c(
const detail::homogeneous_color_base<E,L,N>& p);
74 template <
int K,
typename P,
typename C,
typename L>
75 typename kth_element_reference_type<packed_pixel<P,C,L>, K>::type
78 template <
int K,
typename P,
typename C,
typename L>
79 typename kth_element_const_reference_type<packed_pixel<P,C,L>,K>::type
84 template <
int K,
typename B,
typename C,
typename L,
bool M>
inline
85 typename kth_element_reference_type<bit_aligned_pixel_reference<B,C,L,M>, K>::type
89 template <
int K,
typename ColorBase>
90 typename disable_if<is_const<ColorBase>,
typename kth_semantic_element_reference_type<ColorBase,K>::type>::type
semantic_at_c(ColorBase& p);
91 template <
int K,
typename ColorBase>
92 typename kth_semantic_element_const_reference_type<ColorBase,K>::type
semantic_at_c(
const ColorBase& p);
94 template <
typename T>
struct dynamic_x_step_type;
95 template <
typename T>
struct dynamic_y_step_type;
96 template <
typename T>
struct transposed_type;
100 void initialize_it(T&) {}
103 template <
typename T>
104 struct remove_const_and_reference :
public remove_const<typename remove_reference<T>::type> {};
106 #ifdef BOOST_GIL_USE_CONCEPT_CHECK
107 #define GIL_CLASS_REQUIRE(type_var, ns, concept) BOOST_CLASS_REQUIRE(type_var, ns, concept);
108 template <
typename C>
void gil_function_requires() { function_requires<C>(); }
110 #define GIL_CLASS_REQUIRE(T,NS,C)
111 template <
typename C>
void gil_function_requires() {}
122 template <
typename T>
125 function_requires<boost::DefaultConstructibleConcept<T> >();
137 template <
typename T>
140 function_requires<boost::CopyConstructibleConcept<T> >();
153 template <
typename T>
156 function_requires<boost::AssignableConcept<T> >();
168 template <
typename T>
171 function_requires<boost::EqualityComparableConcept<T> >();
182 template <
typename T,
typename U>
185 BOOST_STATIC_ASSERT((boost::is_same<T,U>::value_core));
197 template <
typename T>
214 template <
typename T>
217 gil_function_requires< boost::DefaultConstructibleConcept<T> >();
218 gil_function_requires< boost::CopyConstructibleConcept<T> >();
219 gil_function_requires< boost::EqualityComparableConcept<T> >();
220 gil_function_requires< boost::AssignableConcept<T> >();
221 gil_function_requires< Swappable<T> >();
233 template <
typename T>
236 typedef typename T::type type;
262 template <
typename P>
265 gil_function_requires< Regular<P> >();
267 typedef typename P::value_type value_type;
268 static const std::size_t N=P::num_dimensions; ignore_unused_variable_warning(N);
269 typedef typename P::template axis<0>::coord_t FT;
270 typedef typename P::template axis<N-1>::coord_t LT;
271 FT ft=gil::axis_value<0>(
point);
272 axis_value<0>(
point)=ft;
273 LT lt=axis_value<N-1>(
point);
274 axis_value<N-1>(
point)=lt;
299 template <
typename P>
302 gil_function_requires< PointNDConcept<P> >();
303 BOOST_STATIC_ASSERT(P::num_dimensions == 2);
320 struct ForwardIteratorIsMutableConcept {
328 struct BidirectionalIteratorIsMutableConcept {
330 gil_function_requires< ForwardIteratorIsMutableConcept<TT> >();
337 struct RandomAccessIteratorIsMutableConcept {
339 gil_function_requires< BidirectionalIteratorIsMutableConcept<TT> >();
340 typename std::iterator_traits<TT>::difference_type n=0; ignore_unused_variable_warning(n);
362 template <
typename Cs>
369 template <
typename ColorSpace1,
typename ColorSpace2>
370 struct color_spaces_are_compatible :
public is_same<ColorSpace1,ColorSpace2> {};
381 template <
typename Cs1,
typename Cs2>
384 BOOST_STATIC_ASSERT((color_spaces_are_compatible<Cs1,Cs2>::value));
397 template <
typename CM>
436 template <
typename T>
439 gil_function_requires< boost::EqualityComparableConcept<T> >();
441 typedef typename channel_traits<T>::value_type v;
442 typedef typename channel_traits<T>::reference r;
443 typedef typename channel_traits<T>::pointer p;
444 typedef typename channel_traits<T>::const_reference cr;
445 typedef typename channel_traits<T>::const_pointer cp;
447 channel_traits<T>::min_value();
448 channel_traits<T>::max_value();
456 template <
typename T>
457 struct ChannelIsMutableConcept {
475 template <
typename T>
478 gil_function_requires<ChannelConcept<T> >();
479 gil_function_requires<detail::ChannelIsMutableConcept<T> >();
490 template <
typename T>
493 gil_function_requires<ChannelConcept<T> >();
494 gil_function_requires<Regular<T> >();
510 template <
typename T1,
typename T2>
512 :
public is_same<typename channel_traits<T1>::value_type, typename channel_traits<T2>::value_type> {};
523 template <
typename T1,
typename T2>
541 template <
typename SrcChannel,
typename DstChannel>
544 gil_function_requires<ChannelConcept<SrcChannel> >();
545 gil_function_requires<MutableChannelConcept<DstChannel> >();
546 dst=channel_convert<DstChannel,SrcChannel>(src); ignore_unused_variable_warning(dst);
604 template <
typename ColorBase>
607 gil_function_requires< CopyConstructible<ColorBase> >();
608 gil_function_requires< EqualityComparable<ColorBase> >();
610 typedef typename ColorBase::layout_t::color_space_t color_space_t;
611 gil_function_requires<ColorSpaceConcept<color_space_t> >();
613 typedef typename ColorBase::layout_t::channel_mapping_t channel_mapping_t;
618 typedef typename kth_element_type<ColorBase,num_elements-1>::type TN;
619 typedef typename kth_element_const_reference_type<ColorBase,num_elements-1>::type CR;
621 CR cr=
gil::at_c<num_elements-1>(cb); ignore_unused_variable_warning(cr);
624 semantic_at_c<0>(cb);
647 template <
typename ColorBase>
650 gil_function_requires< ColorBaseConcept<ColorBase> >();
651 gil_function_requires< Assignable<ColorBase> >();
652 gil_function_requires< Swappable<ColorBase> >();
654 typedef typename kth_element_reference_type<ColorBase, 0>::type CR;
656 CR r=gil::at_c<0>(cb);
671 template <
typename ColorBase>
674 gil_function_requires< MutableColorBaseConcept<ColorBase> >();
675 gil_function_requires< Regular<ColorBase> >();
691 template <
typename ColorBase>
694 gil_function_requires< ColorBaseConcept<ColorBase> >();
698 typedef typename kth_element_type<ColorBase,0>::type T0;
699 typedef typename kth_element_type<ColorBase,num_elements-1>::type TN;
701 BOOST_STATIC_ASSERT((is_same<T0,TN>::value));
702 typedef typename kth_element_const_reference_type<ColorBase,0>::type CRef0;
703 CRef0 e0=dynamic_at_c(cb,0);
719 template <
typename ColorBase>
722 gil_function_requires< ColorBaseConcept<ColorBase> >();
723 gil_function_requires< HomogeneousColorBaseConcept<ColorBase> >();
724 typedef typename kth_element_reference_type<ColorBase, 0>::type R0;
725 R0 x=dynamic_at_c(cb,0);
726 dynamic_at_c(cb,0) = dynamic_at_c(cb,0);
741 template <
typename ColorBase>
744 gil_function_requires< MutableHomogeneousColorBaseConcept<ColorBase> >();
745 gil_function_requires< Regular<ColorBase> >();
763 template <
typename ColorBase1,
typename ColorBase2>
766 BOOST_STATIC_ASSERT((is_same<
typename ColorBase1::layout_t::color_space_t,
767 typename ColorBase2::layout_t::color_space_t>::value));
818 template <
typename P>
821 typedef typename color_space_type<P>::type color_space_t;
822 gil_function_requires<ColorSpaceConcept<color_space_t> >();
823 typedef typename channel_mapping_type<P>::type channel_mapping_t;
824 gil_function_requires<ChannelMappingConcept<channel_mapping_t> >();
826 static const bool planar = is_planar<P>::type::value; ignore_unused_variable_warning(planar);
831 ignore_unused_variable_warning(nc);
846 template <
typename P>
849 gil_function_requires<PixelBasedConcept<P> >();
851 gil_function_requires<ChannelConcept<channel_t> >();
880 template <
typename P>
883 gil_function_requires<ColorBaseConcept<P> >();
884 gil_function_requires<PixelBasedConcept<P> >();
886 BOOST_STATIC_ASSERT((is_pixel<P>::value));
887 static const bool is_mutable = P::is_mutable; ignore_unused_variable_warning(is_mutable);
889 typedef typename P::value_type value_type;
892 typedef typename P::reference reference;
893 gil_function_requires<PixelConcept<typename remove_const_and_reference<reference>::type> >();
895 typedef typename P::const_reference const_reference;
896 gil_function_requires<PixelConcept<typename remove_const_and_reference<const_reference>::type> >();
910 template <
typename P>
913 gil_function_requires<PixelConcept<P> >();
914 BOOST_STATIC_ASSERT(P::is_mutable);
926 template <
typename P>
929 gil_function_requires<PixelConcept<P> >();
930 gil_function_requires<HomogeneousColorBaseConcept<P> >();
931 gil_function_requires<HomogeneousPixelBasedConcept<P> >();
946 template <
typename P>
949 gil_function_requires<HomogeneousPixelConcept<P> >();
950 gil_function_requires<MutableHomogeneousColorBaseConcept<P> >();
967 template <
typename P>
970 gil_function_requires<PixelConcept<P> >();
971 gil_function_requires<Regular<P> >();
984 template <
typename P>
987 gil_function_requires<HomogeneousPixelConcept<P> >();
988 gil_function_requires<Regular<P> >();
989 BOOST_STATIC_ASSERT((is_same<P, typename P::value_type>::value));
994 template <
typename P1,
typename P2,
int K>
995 struct channels_are_pairwise_compatible :
public
996 mpl::and_<channels_are_pairwise_compatible<P1,P2,K-1>,
997 channels_are_compatible<typename kth_semantic_element_reference_type<P1,K>::type,
998 typename kth_semantic_element_reference_type<P2,K>::type> > {};
1000 template <
typename P1,
typename P2>
1001 struct channels_are_pairwise_compatible<P1,P2,-1> :
public mpl::true_ {};
1008 template <
typename P1,
typename P2>
1010 :
public mpl::and_<typename color_spaces_are_compatible<typename color_space_type<P1>::type,
1011 typename color_space_type<P2>::type>::type,
1012 detail::channels_are_pairwise_compatible<P1,P2,num_channels<P1>::value-1> > {};
1025 template <
typename P1,
typename P2>
1027 void constraints() {
1044 template <
typename SrcP,
typename DstP>
1046 void constraints() {
1047 gil_function_requires<PixelConcept<SrcP> >();
1048 gil_function_requires<MutablePixelConcept<DstP> >();
1081 template <
typename D>
1083 void constraints() {
1084 gil_function_requires< boost::UnaryFunctionConcept<D,
1085 typename remove_const_and_reference<typename D::result_type>::type,
1086 typename D::argument_type> >();
1087 gil_function_requires< boost::DefaultConstructibleConcept<D> >();
1088 gil_function_requires< boost::CopyConstructibleConcept<D> >();
1089 gil_function_requires< boost::AssignableConcept<D> >();
1091 gil_function_requires<PixelConcept<typename remove_const_and_reference<typename D::result_type>::type> >();
1093 typedef typename D::const_t const_t;
1094 gil_function_requires<PixelDereferenceAdaptorConcept<const_t> >();
1095 typedef typename D::value_type value_type;
1096 gil_function_requires<PixelValueConcept<value_type> >();
1097 typedef typename D::reference reference;
1098 typedef typename D::const_reference const_reference;
1100 const bool is_mutable=D::is_mutable; ignore_unused_variable_warning(is_mutable);
1105 template <
typename P>
1106 struct PixelDereferenceAdaptorArchetype {
1107 typedef P argument_type;
1108 typedef P result_type;
1109 typedef PixelDereferenceAdaptorArchetype const_t;
1110 typedef typename remove_reference<P>::type value_type;
1111 typedef typename add_reference<P>::type reference;
1112 typedef reference const_reference;
1113 static const bool is_mutable=
false;
1114 P operator()(P)
const {
throw; }
1133 template <
typename T>
1135 void constraints() {
1136 typedef typename dynamic_x_step_type<T>::type type;
1150 template <
typename T>
1152 void constraints() {
1153 typedef typename dynamic_y_step_type<T>::type type;
1168 template <
typename T>
1170 void constraints() {
1171 typedef typename transposed_type<T>::type type;
1197 template <
typename Iterator>
1199 void constraints() {
1200 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<Iterator> >();
1201 gil_function_requires<PixelBasedConcept<Iterator> >();
1203 typedef typename std::iterator_traits<Iterator>::value_type value_type;
1204 gil_function_requires<PixelValueConcept<value_type> >();
1209 const_t const_it(it); ignore_unused_variable_warning(const_it);
1213 void check_base(mpl::false_) {}
1214 void check_base(mpl::true_) {
1216 gil_function_requires<PixelIteratorConcept<base_t> >();
1223 template <
typename Iterator>
1224 struct PixelIteratorIsMutableConcept {
1225 void constraints() {
1226 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<Iterator> >();
1227 typedef typename remove_reference<typename std::iterator_traits<Iterator>::reference>::type ref;
1229 gil_function_requires<detail::ChannelIsMutableConcept<channel_t> >();
1242 template <
typename Iterator>
1244 void constraints() {
1245 gil_function_requires<PixelIteratorConcept<Iterator> >();
1246 gil_function_requires<detail::PixelIteratorIsMutableConcept<Iterator> >();
1252 template <
typename Iterator>
1253 struct RandomAccessIteratorIsMemoryBasedConcept {
1254 void constraints() {
1255 std::ptrdiff_t bs=memunit_step(it); ignore_unused_variable_warning(bs);
1256 it=memunit_advanced(it,3);
1257 std::ptrdiff_t bd=memunit_distance(it,it); ignore_unused_variable_warning(bd);
1258 memunit_advance(it,3);
1283 template <
typename Iterator>
1285 void constraints() {
1286 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<Iterator> >();
1287 gil_function_requires<detail::RandomAccessIteratorIsMemoryBasedConcept<Iterator> >();
1302 template <
typename Iterator>
1304 void constraints() {
1305 gil_function_requires<boost_concepts::ForwardTraversalConcept<Iterator> >();
1320 template <
typename Iterator>
1322 void constraints() {
1323 gil_function_requires<StepIteratorConcept<Iterator> >();
1324 gil_function_requires<detail::ForwardIteratorIsMutableConcept<Iterator> >();
1359 template <
typename Iterator>
1361 void constraints() {
1362 gil_function_requires<boost_concepts::ForwardTraversalConcept<Iterator> >();
1365 gil_function_requires<boost_concepts::ForwardTraversalConcept<base_t> >();
1370 base_t base=it.base(); ignore_unused_variable_warning(base);
1382 template <
typename Iterator>
1384 void constraints() {
1385 gil_function_requires<IteratorAdaptorConcept<Iterator> >();
1386 gil_function_requires<detail::ForwardIteratorIsMutableConcept<Iterator> >();
1456 template <
typename Loc>
1458 void constraints() {
1459 gil_function_requires< Regular<Loc> >();
1461 typedef typename Loc::value_type value_type;
1462 typedef typename Loc::reference reference;
1463 typedef typename Loc::difference_type difference_type;
1464 typedef typename Loc::cached_location_t cached_location_t;
1465 typedef typename Loc::const_t const_t;
1466 typedef typename Loc::point_t
point_t;
1467 static const std::size_t N=Loc::num_dimensions; ignore_unused_variable_warning(N);
1469 typedef typename Loc::template axis<0>::iterator first_it_type;
1470 typedef typename Loc::template axis<N-1>::iterator last_it_type;
1471 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<first_it_type> >();
1472 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<last_it_type> >();
1475 gil_function_requires<PointNDConcept<point_t> >();
1476 BOOST_STATIC_ASSERT(point_t::num_dimensions==N);
1477 BOOST_STATIC_ASSERT((is_same<
typename std::iterator_traits<first_it_type>::difference_type,
typename point_t::template axis<0>::coord_t>::value));
1478 BOOST_STATIC_ASSERT((is_same<
typename std::iterator_traits<last_it_type>::difference_type,
typename point_t::template axis<N-1>::coord_t>::value));
1485 reference r1=loc[d]; ignore_unused_variable_warning(r1);
1486 reference r2=*loc; ignore_unused_variable_warning(r2);
1487 cached_location_t cl=loc.cache_location(d); ignore_unused_variable_warning(cl);
1488 reference r3=loc[d]; ignore_unused_variable_warning(r3);
1490 first_it_type fi=loc.template axis_iterator<0>();
1491 fi=loc.template axis_iterator<0>(d);
1492 last_it_type li=loc.template axis_iterator<N-1>();
1493 li=loc.template axis_iterator<N-1>(d);
1495 typedef PixelDereferenceAdaptorArchetype<typename Loc::value_type> deref_t;
1496 typedef typename Loc::template add_deref<deref_t>::type dtype;
1542 template <
typename Loc>
1544 void constraints() {
1545 gil_function_requires<RandomAccessNDLocatorConcept<Loc> >();
1546 BOOST_STATIC_ASSERT(Loc::num_dimensions==2);
1548 typedef typename dynamic_x_step_type<Loc>::type dynamic_x_step_t;
1549 typedef typename dynamic_y_step_type<Loc>::type dynamic_y_step_t;
1550 typedef typename transposed_type<Loc>::type transposed_t;
1552 typedef typename Loc::cached_location_t cached_location_t;
1553 gil_function_requires<Point2DConcept<typename Loc::point_t> >();
1555 typedef typename Loc::x_iterator x_iterator;
1556 typedef typename Loc::y_iterator y_iterator;
1557 typedef typename Loc::x_coord_t x_coord_t;
1558 typedef typename Loc::y_coord_t y_coord_t;
1560 x_coord_t xd=0; ignore_unused_variable_warning(xd);
1561 y_coord_t yd=0; ignore_unused_variable_warning(yd);
1563 typename Loc::difference_type d;
1564 typename Loc::reference r=loc(xd,yd); ignore_unused_variable_warning(r);
1566 dynamic_x_step_t loc2(dynamic_x_step_t(), yd);
1567 dynamic_x_step_t loc3(dynamic_x_step_t(), xd, yd);
1569 typedef typename dynamic_y_step_type<typename dynamic_x_step_type<transposed_t>::type>::type dynamic_xy_step_transposed_t;
1570 dynamic_xy_step_transposed_t loc4(loc, xd,yd,
true);
1572 bool is_contiguous=loc.is_1d_traversable(xd); ignore_unused_variable_warning(is_contiguous);
1573 loc.y_distance_to(loc, xd);
1576 loc=loc.xy_at(xd,yd);
1578 x_iterator xit=loc.x_at(d);
1579 xit=loc.x_at(xd,yd);
1582 y_iterator yit=loc.y_at(d);
1583 yit=loc.y_at(xd,yd);
1586 cached_location_t cl=loc.cache_location(xd,yd); ignore_unused_variable_warning(cl);
1605 template <
typename Loc>
1607 void constraints() {
1608 gil_function_requires< RandomAccess2DLocatorConcept<Loc> >();
1609 gil_function_requires< PixelIteratorConcept<typename Loc::x_iterator> >();
1610 gil_function_requires< PixelIteratorConcept<typename Loc::y_iterator> >();
1611 typedef typename Loc::coord_t coord_t;
1612 BOOST_STATIC_ASSERT((is_same<typename Loc::x_coord_t, typename Loc::y_coord_t>::value));
1618 template <
typename Loc>
1619 struct RandomAccessNDLocatorIsMutableConcept {
1620 void constraints() {
1621 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<typename Loc::template axis<0>::iterator> >();
1622 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<
typename Loc::template axis<Loc::num_dimensions-1>::iterator> >();
1624 typename Loc::difference_type d; initialize_it(d);
1625 typename Loc::value_type v;initialize_it(v);
1626 typename Loc::cached_location_t cl=loc.cache_location(d);
1634 template <
typename Loc>
1635 struct RandomAccess2DLocatorIsMutableConcept {
1636 void constraints() {
1637 gil_function_requires<detail::RandomAccessNDLocatorIsMutableConcept<Loc> >();
1638 typename Loc::x_coord_t xd=0; ignore_unused_variable_warning(xd);
1639 typename Loc::y_coord_t yd=0; ignore_unused_variable_warning(yd);
1640 typename Loc::value_type v; initialize_it(v);
1656 template <
typename Loc>
1658 void constraints() {
1659 gil_function_requires<RandomAccessNDLocatorConcept<Loc> >();
1660 gil_function_requires<detail::RandomAccessNDLocatorIsMutableConcept<Loc> >();
1671 template <
typename Loc>
1673 void constraints() {
1674 gil_function_requires< RandomAccess2DLocatorConcept<Loc> >();
1675 gil_function_requires<detail::RandomAccess2DLocatorIsMutableConcept<Loc> >();
1686 template <
typename Loc>
1688 void constraints() {
1689 gil_function_requires<PixelLocatorConcept<Loc> >();
1690 gil_function_requires<detail::RandomAccess2DLocatorIsMutableConcept<Loc> >();
1763 template <
typename View>
1765 void constraints() {
1766 gil_function_requires< Regular<View> >();
1768 typedef typename View::value_type value_type;
1769 typedef typename View::reference reference;
1770 typedef typename View::pointer pointer;
1771 typedef typename View::difference_type difference_type;
1772 typedef typename View::const_t const_t;
1773 typedef typename View::point_t
point_t;
1774 typedef typename View::locator locator;
1775 typedef typename View::iterator iterator;
1776 typedef typename View::const_iterator const_iterator;
1777 typedef typename View::reverse_iterator reverse_iterator;
1778 typedef typename View::size_type size_type;
1779 static const std::size_t N=View::num_dimensions;
1781 gil_function_requires<RandomAccessNDLocatorConcept<locator> >();
1782 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<iterator> >();
1783 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<reverse_iterator> >();
1785 typedef typename View::template axis<0>::iterator first_it_type;
1786 typedef typename View::template axis<N-1>::iterator last_it_type;
1787 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<first_it_type> >();
1788 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<last_it_type> >();
1794 gil_function_requires<PointNDConcept<point_t> >();
1795 BOOST_STATIC_ASSERT(point_t::num_dimensions==N);
1796 BOOST_STATIC_ASSERT((is_same<
typename std::iterator_traits<first_it_type>::difference_type,
typename point_t::template axis<0>::coord_t>::value));
1797 BOOST_STATIC_ASSERT((is_same<
typename std::iterator_traits<last_it_type>::difference_type,
typename point_t::template axis<N-1>::coord_t>::value));
1802 reverse_iterator rit;
1803 difference_type d; detail::initialize_it(d); ignore_unused_variable_warning(d);
1807 p=view.dimensions();
1809 size_type sz=view.size(); ignore_unused_variable_warning(sz);
1810 bool is_contiguous=view.is_1d_traversable(); ignore_unused_variable_warning(is_contiguous);
1817 reference r1=view[d]; ignore_unused_variable_warning(r1);
1818 reference r2=view(p); ignore_unused_variable_warning(r2);
1821 first_it_type fi=view.template axis_iterator<0>(p); ignore_unused_variable_warning(fi);
1822 last_it_type li=view.template axis_iterator<N-1>(p); ignore_unused_variable_warning(li);
1824 typedef PixelDereferenceAdaptorArchetype<typename View::value_type> deref_t;
1825 typedef typename View::template add_deref<deref_t>::type dtype;
1869 template <
typename View>
1871 void constraints() {
1872 gil_function_requires<RandomAccessNDImageViewConcept<View> >();
1873 BOOST_STATIC_ASSERT(View::num_dimensions==2);
1876 gil_function_requires<RandomAccess2DLocatorConcept<typename View::locator> >();
1878 typedef typename dynamic_x_step_type<View>::type dynamic_x_step_t;
1879 typedef typename dynamic_y_step_type<View>::type dynamic_y_step_t;
1880 typedef typename transposed_type<View>::type transposed_t;
1882 typedef typename View::x_iterator x_iterator;
1883 typedef typename View::y_iterator y_iterator;
1884 typedef typename View::x_coord_t x_coord_t;
1885 typedef typename View::y_coord_t y_coord_t;
1886 typedef typename View::xy_locator xy_locator;
1888 x_coord_t xd=0; ignore_unused_variable_warning(xd);
1889 y_coord_t yd=0; ignore_unused_variable_warning(yd);
1892 typename View::point_t d;
1894 View(xd,yd,xy_locator());
1896 xy_locator lc=view.xy_at(xd,yd);
1899 typename View::reference r=view(xd,yd); ignore_unused_variable_warning(r);
1904 xit=view.x_at(xd,yd);
1905 xit=view.row_begin(xd);
1906 xit=view.row_end(xd);
1909 yit=view.y_at(xd,yd);
1910 yit=view.col_begin(xd);
1911 yit=view.col_end(xd);
1919 template <
typename View>
1924 using value_type =
typename View::value_type;
1925 using iterator =
typename View::iterator;
1926 using const_iterator =
typename View::const_iterator;
1927 using reference =
typename View::reference;
1928 using const_reference =
typename View::const_reference;
1929 using pointer =
typename View::pointer;
1930 using difference_type =
typename View::difference_type;
1931 using size_type=
typename View::size_type;
1944 boost::ignore_unused(s);
1957 template <
typename View>
1962 gil_function_requires<CollectionImageViewConcept<View>>();
1964 using reference =
typename View::reference;
1965 using const_reference =
typename View::const_reference;
1967 reference r = view.front();
1968 boost::ignore_unused(r);
1970 const_reference cr = view.front();
1971 boost::ignore_unused(cr);
1979 template <
typename View>
1984 gil_function_requires<CollectionImageViewConcept<View>>();
1986 using reverse_iterator =
typename View::reverse_iterator;
1987 using reference =
typename View::reference;
1988 using const_reference =
typename View::const_reference;
1994 reference r = view.back();
1995 boost::ignore_unused(r);
1997 const_reference cr = view.back();
1998 boost::ignore_unused(cr);
2019 template <
typename View>
2021 void constraints() {
2022 gil_function_requires<RandomAccess2DImageViewConcept<View> >();
2025 gil_function_requires<PixelLocatorConcept<typename View::xy_locator> >();
2027 BOOST_STATIC_ASSERT((is_same<typename View::x_coord_t, typename View::y_coord_t>::value));
2029 typedef typename View::coord_t coord_t;
2030 std::size_t num_chan = view.num_channels(); ignore_unused_variable_warning(num_chan);
2037 template <
typename View>
2038 struct RandomAccessNDImageViewIsMutableConcept {
2039 void constraints() {
2040 gil_function_requires<detail::RandomAccessNDLocatorIsMutableConcept<typename View::locator> >();
2042 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<typename View::iterator> >();
2043 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<typename View::reverse_iterator> >();
2044 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<typename View::template axis<0>::iterator> >();
2045 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<
typename View::template axis<View::num_dimensions-1>::iterator> >();
2047 typename View::difference_type diff; initialize_it(diff); ignore_unused_variable_warning(diff);
2048 typename View::point_t pt;
2049 typename View::value_type v; initialize_it(v);
2057 template <
typename View>
2058 struct RandomAccess2DImageViewIsMutableConcept {
2059 void constraints() {
2060 gil_function_requires<detail::RandomAccessNDImageViewIsMutableConcept<View> >();
2061 typename View::x_coord_t xd=0; ignore_unused_variable_warning(xd);
2062 typename View::y_coord_t yd=0; ignore_unused_variable_warning(yd);
2063 typename View::value_type v; initialize_it(v);
2069 template <
typename View>
2070 struct PixelImageViewIsMutableConcept {
2071 void constraints() {
2072 gil_function_requires<detail::RandomAccess2DImageViewIsMutableConcept<View> >();
2086 template <
typename View>
2088 void constraints() {
2089 gil_function_requires<RandomAccessNDImageViewConcept<View> >();
2090 gil_function_requires<detail::RandomAccessNDImageViewIsMutableConcept<View> >();
2101 template <
typename View>
2103 void constraints() {
2104 gil_function_requires<RandomAccess2DImageViewConcept<View> >();
2105 gil_function_requires<detail::RandomAccess2DImageViewIsMutableConcept<View> >();
2116 template <
typename View>
2118 void constraints() {
2119 gil_function_requires<ImageViewConcept<View> >();
2120 gil_function_requires<detail::PixelImageViewIsMutableConcept<View> >();
2127 template <
typename V1,
typename V2>
2139 template <
typename V1,
typename V2>
2141 void constraints() {
2176 template <
typename Img>
2178 void constraints() {
2179 gil_function_requires<Regular<Img> >();
2181 typedef typename Img::view_t view_t;
2182 gil_function_requires<MutableRandomAccessNDImageViewConcept<view_t> >();
2184 typedef typename Img::const_view_t const_view_t;
2185 typedef typename Img::value_type pixel_t;
2187 typedef typename Img::point_t
point_t;
2188 gil_function_requires<PointNDConcept<point_t> >();
2190 const_view_t cv =
const_view(img); ignore_unused_variable_warning(cv);
2191 view_t v =
view(img); ignore_unused_variable_warning(v);
2194 point_t pt=img.dimensions();
2197 Img im3(pt,fill_value,1);
2200 img.recreate(pt,fill_value,1);
2225 template <
typename Img>
2227 void constraints() {
2228 gil_function_requires<RandomAccessNDImageConcept<Img> >();
2229 typedef typename Img::x_coord_t x_coord_t;
2230 typedef typename Img::y_coord_t y_coord_t;
2231 typedef typename Img::value_type value_t;
2233 gil_function_requires<MutableRandomAccess2DImageViewConcept<typename Img::view_t> >();
2235 x_coord_t w=img.width();
2236 y_coord_t h=img.height();
2240 Img im3(w,h,fill_value,1);
2242 img.recreate(w,h,1);
2243 img.recreate(w,h,fill_value,1);
2258 template <
typename Img>
2260 void constraints() {
2261 gil_function_requires<RandomAccess2DImageConcept<Img> >();
2262 gil_function_requires<MutableImageViewConcept<typename Img::view_t> >();
2263 typedef typename Img::coord_t coord_t;
2266 BOOST_STATIC_ASSERT((is_same<coord_t, typename Img::x_coord_t>::value));
2267 BOOST_STATIC_ASSERT((is_same<coord_t, typename Img::y_coord_t>::value));
2272 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
2273 #pragma warning(pop)
2276 #if defined(__GNUC__) && (__GNUC__ >= 4)
2277 #pragma GCC diagnostic pop
Represents a unary function object that can be invoked upon dereferencing a pixel iterator...
Definition: concepts.hpp:1082
Concept for iterators, locators and views that can define a type just like the given iterator/locator...
Definition: concepts.hpp:1134
metafunction predicate determining whether the given iterator is a plain one or an adaptor over anoth...
Definition: concepts.hpp:60
Homogeneous color base that also has a default constructor. Refines Regular.
Definition: concepts.hpp:742
Definition: concepts.hpp:169
Homogeneous pixel concept that allows for changing its channels.
Definition: concepts.hpp:947
2-dimensional view over mutable values
Definition: concepts.hpp:2102
Homogeneous color base that allows for modifying its elements.
Definition: concepts.hpp:720
Pixel iterator that allows for changing its pixel.
Definition: concepts.hpp:1243
Definition: concepts.hpp:183
N-dimensional locator over mutable pixels.
Definition: concepts.hpp:1657
Definition: concepts.hpp:138
Concept of a random-access iterator that can be advanced in memory units (bytes or bits) ...
Definition: concepts.hpp:1284
disable_if< is_const< ColorBase >, typename kth_semantic_element_reference_type< ColorBase, K >::type >::type semantic_at_c(ColorBase &p)
A mutable accessor to the K-th semantic element of a color base.
Definition: color_base_algorithm.hpp:106
2-dimensional locator over mutable pixels
Definition: concepts.hpp:1672
returns the base iterator for a given iterator adaptor. Provide an specialization when introducing ne...
Definition: concepts.hpp:62
Two color bases are compatible if they have the same color space and their elements are compatible...
Definition: concepts.hpp:764
Iterator adaptor is a forward iterator adapting another forward iterator.
Definition: concepts.hpp:1360
Concept for pixel compatibility Pixels are compatible if their channels and color space types are com...
Definition: concepts.hpp:1026
N-dimensional view over mutable values.
Definition: concepts.hpp:2087
void swap(const boost::gil::packed_channel_reference< BF, FB, NB, M > x, R &y)
swap for packed_channel_reference
Definition: channel.hpp:480
Pixel concept that is a Regular type.
Definition: concepts.hpp:968
channel_traits< DstChannel >::value_type channel_convert(const SrcChannel &src)
Converting from one channel type to another.
Definition: channel_algorithm.hpp:398
N-dimensional container of values.
Definition: concepts.hpp:2177
Step iterator that allows for modifying its current value.
Definition: concepts.hpp:1321
Specifies the element type of a homogeneous color base.
Definition: color_base_algorithm.hpp:200
Concept for locators and views that can define a type just like the given locator or view...
Definition: concepts.hpp:1151
Definition: concepts.hpp:198
A channel is convertible to another one if the channel_convert algorithm is defined for the two chann...
Definition: concepts.hpp:542
2-dimensional image whose value type models PixelValueConcept
Definition: concepts.hpp:2259
Heterogeneous pixel reference corresponding to non-byte-aligned bit range. Models ColorBaseConcept...
Definition: bit_aligned_pixel_reference.hpp:113
A color base is a container of color elements (such as channels, channel references or channel pointe...
Definition: concepts.hpp:605
A channel is the building block of a color. Color is defined as a mixture of primary colors and a cha...
Definition: concepts.hpp:437
add_reference< E >::type at_c(detail::homogeneous_color_base< E, L, N > &p)
Provides mutable access to the K-th element, in physical order.
Definition: color_base.hpp:381
Concept for homogeneous pixel-based GIL constructs.
Definition: concepts.hpp:847
Color base which allows for modifying its elements.
Definition: concepts.hpp:648
2-dimensional locator over immutable values
Definition: concepts.hpp:1543
Specifies the return type of the mutable semantic_at_c<K>(color_base);.
Definition: color_base_algorithm.hpp:88
Concept for all pixel-based GIL constructs, such as pixels, iterators, locators, views and images who...
Definition: concepts.hpp:819
GIL view as Collection.
Definition: concepts.hpp:1920
Definition: concepts.hpp:123
Returns whether two views are compatible.
Definition: concepts.hpp:2128
A channel that supports default construction.
Definition: concepts.hpp:491
Concept for locators and views that can define a type just like the given locator or view...
Definition: concepts.hpp:1169
Predicate metafunction returning whether two channels are compatibleChannels are considered compatibl...
Definition: concepts.hpp:511
GIL's 2-dimensional locator over immutable GIL pixels.
Definition: concepts.hpp:1606
Channel mapping concept.
Definition: concepts.hpp:398
GIL view as ReversibleCollection.
Definition: concepts.hpp:1980
Homogeneous pixel concept that is a Regular type.
Definition: concepts.hpp:985
Homogeneous pixel concept.
Definition: concepts.hpp:927
Pixel concept that allows for changing its channels.
Definition: concepts.hpp:911
Color space type concept.
Definition: concepts.hpp:363
Definition: concepts.hpp:154
Pixel convertible concept.
Definition: concepts.hpp:1045
Definition: color_convert.hpp:30
GIL's 2-dimensional view over mutable GIL pixels.
Definition: concepts.hpp:2117
Channels are compatible if their associated value types (ignoring constness and references) are the s...
Definition: concepts.hpp:524
2-dimensional container of values
Definition: concepts.hpp:2226
void color_convert(const SrcP &src, DstP &dst)
helper function for converting one pixel to another using GIL default color-converters where ScrP mod...
Definition: color_convert.hpp:296
N-dimensional point concept.
Definition: concepts.hpp:263
Color base that also has a default-constructor. Refines Regular.
Definition: concepts.hpp:672
2-dimensional point concept
Definition: concepts.hpp:300
Changes the base iterator of an iterator adaptor. Provide an specialization when introducing new iter...
Definition: concepts.hpp:61
Returns whether two pixels are compatible.
Definition: concepts.hpp:1009
Iterator adaptor that is mutable.
Definition: concepts.hpp:1383
GIL's 2-dimensional view over immutable GIL pixels.
Definition: concepts.hpp:2020
const image< Pixel, IsPlanar, Alloc >::view_t & view(image< Pixel, IsPlanar, Alloc > &img)
Returns the non-constant-pixel view of an image.
Definition: image.hpp:460
Two color spaces are compatible if they are the same.
Definition: concepts.hpp:382
Metafunction predicate returning whether the given iterator allows for changing its values...
Definition: concepts.hpp:59
2-dimensional view over immutable values
Definition: concepts.hpp:1870
Heterogeneous pixel value whose channel references can be constructed from the pixel bitfield and the...
Definition: concepts.hpp:73
Returns an MPL integral type specifying the number of elements in a color base.
Definition: color_base_algorithm.hpp:45
GIL view as ForwardCollection.
Definition: concepts.hpp:1958
An STL random access traversal iterator over a model of PixelConcept.
Definition: concepts.hpp:1198
const image< Pixel, IsPlanar, Alloc >::const_view_t const_view(const image< Pixel, IsPlanar, Alloc > &img)
Returns the constant-pixel view of an image.
Definition: image.hpp:464
Views are compatible if they have the same color spaces and compatible channel values. Constness and layout are not important for compatibility.
Definition: concepts.hpp:2140
Returns the type of an iterator just like the input iterator, except operating over immutable values...
Definition: concepts.hpp:58
Step iterator concept.
Definition: concepts.hpp:1303
N-dimensional view over immutable values.
Definition: concepts.hpp:1764
Returns the number of channels of a pixel-based GIL construct.
Definition: concepts.hpp:56
A channel that allows for modifying its value.
Definition: concepts.hpp:476
Specifies the return type of the constant semantic_at_c<K>(color_base);.
Definition: color_base_algorithm.hpp:96
Color base whose elements all have the same type.
Definition: concepts.hpp:692
N-dimensional locator over immutable values.
Definition: concepts.hpp:1457
Definition: concepts.hpp:215
Pixel concept - A color base whose elements are channels.
Definition: concepts.hpp:881
2D point both axes of which have the same dimension typeModels: Point2DConcept
Definition: concepts.hpp:42
GIL's 2-dimensional locator over mutable GIL pixels.
Definition: concepts.hpp:1687