123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- #ifndef BOOST_GIL_CONCEPTS_PIXEL_ITERATOR_HPP
- #define BOOST_GIL_CONCEPTS_PIXEL_ITERATOR_HPP
- #include <boost/gil/concepts/channel.hpp>
- #include <boost/gil/concepts/color.hpp>
- #include <boost/gil/concepts/concept_check.hpp>
- #include <boost/gil/concepts/fwd.hpp>
- #include <boost/gil/concepts/pixel.hpp>
- #include <boost/gil/concepts/pixel_based.hpp>
- #include <boost/iterator/iterator_concepts.hpp>
- #include <cstddef>
- #include <iterator>
- #include <type_traits>
- #if defined(BOOST_CLANG)
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wunknown-pragmas"
- #pragma clang diagnostic ignored "-Wunused-local-typedefs"
- #endif
- #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
- #endif
- namespace boost { namespace gil {
- template <typename It> struct const_iterator_type;
- template <typename It> struct iterator_is_mutable;
- template <typename It> struct is_iterator_adaptor;
- template <typename It, typename NewBaseIt> struct iterator_adaptor_rebind;
- template <typename It> struct iterator_adaptor_get_base;
- namespace detail {
- template <class TT>
- struct ForwardIteratorIsMutableConcept
- {
- void constraints()
- {
- auto const tmp = *i;
- *i++ = tmp;
- }
- TT i;
- };
- template <class TT>
- struct BidirectionalIteratorIsMutableConcept
- {
- void constraints()
- {
- gil_function_requires< ForwardIteratorIsMutableConcept<TT>>();
- auto const tmp = *i;
- *i-- = tmp;
- }
- TT i;
- };
- template <class TT>
- struct RandomAccessIteratorIsMutableConcept
- {
- void constraints()
- {
- gil_function_requires<BidirectionalIteratorIsMutableConcept<TT>>();
- typename std::iterator_traits<TT>::difference_type n = 0;
- ignore_unused_variable_warning(n);
- i[n] = *i;
- }
- TT i;
- };
- template <typename Iterator>
- struct RandomAccessIteratorIsMemoryBasedConcept
- {
- void constraints()
- {
- std::ptrdiff_t bs = memunit_step(it);
- ignore_unused_variable_warning(bs);
- it = memunit_advanced(it, 3);
- std::ptrdiff_t bd = memunit_distance(it, it);
- ignore_unused_variable_warning(bd);
- memunit_advance(it,3);
-
- }
- Iterator it;
- };
- template <typename Iterator>
- struct PixelIteratorIsMutableConcept
- {
- void constraints()
- {
- gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<Iterator>>();
- using ref_t = typename std::remove_reference
- <
- typename std::iterator_traits<Iterator>::reference
- >::type;
- using channel_t = typename element_type<ref_t>::type;
- gil_function_requires<detail::ChannelIsMutableConcept<channel_t>>();
- }
- };
- }
- template <typename T>
- struct HasTransposedTypeConcept
- {
- void constraints()
- {
- using type = typename transposed_type<T>::type;
- ignore_unused_variable_warning(type{});
- }
- };
- template <typename Iterator>
- struct PixelIteratorConcept
- {
- void constraints()
- {
- gil_function_requires<boost_concepts::RandomAccessTraversalConcept<Iterator>>();
- gil_function_requires<PixelBasedConcept<Iterator>>();
- using value_type = typename std::iterator_traits<Iterator>::value_type;
- gil_function_requires<PixelValueConcept<value_type>>();
- using const_t = typename const_iterator_type<Iterator>::type;
- static bool const is_mutable = iterator_is_mutable<Iterator>::value;
- ignore_unused_variable_warning(is_mutable);
-
- const_t const_it(it);
- ignore_unused_variable_warning(const_it);
- check_base(typename is_iterator_adaptor<Iterator>::type());
- }
- void check_base(std::false_type) {}
- void check_base(std::true_type)
- {
- using base_t = typename iterator_adaptor_get_base<Iterator>::type;
- gil_function_requires<PixelIteratorConcept<base_t>>();
- }
- Iterator it;
- };
- template <typename Iterator>
- struct MutablePixelIteratorConcept
- {
- void constraints()
- {
- gil_function_requires<PixelIteratorConcept<Iterator>>();
- gil_function_requires<detail::PixelIteratorIsMutableConcept<Iterator>>();
- }
- };
- template <typename Iterator>
- struct MemoryBasedIteratorConcept
- {
- void constraints()
- {
- gil_function_requires<boost_concepts::RandomAccessTraversalConcept<Iterator>>();
- gil_function_requires<detail::RandomAccessIteratorIsMemoryBasedConcept<Iterator>>();
- }
- };
- template <typename Iterator>
- struct StepIteratorConcept
- {
- void constraints()
- {
- gil_function_requires<boost_concepts::ForwardTraversalConcept<Iterator>>();
- it.set_step(0);
- }
- Iterator it;
- };
- template <typename Iterator>
- struct MutableStepIteratorConcept
- {
- void constraints()
- {
- gil_function_requires<StepIteratorConcept<Iterator>>();
- gil_function_requires<detail::ForwardIteratorIsMutableConcept<Iterator>>();
- }
- };
- template <typename Iterator>
- struct IteratorAdaptorConcept
- {
- void constraints()
- {
- gil_function_requires<boost_concepts::ForwardTraversalConcept<Iterator>>();
- using base_t = typename iterator_adaptor_get_base<Iterator>::type;
- gil_function_requires<boost_concepts::ForwardTraversalConcept<base_t>>();
- static_assert(is_iterator_adaptor<Iterator>::value, "");
- using rebind_t = typename iterator_adaptor_rebind<Iterator, void*>::type;
- base_t base = it.base();
- ignore_unused_variable_warning(base);
- }
- Iterator it;
- };
- template <typename Iterator>
- struct MutableIteratorAdaptorConcept
- {
- void constraints()
- {
- gil_function_requires<IteratorAdaptorConcept<Iterator>>();
- gil_function_requires<detail::ForwardIteratorIsMutableConcept<Iterator>>();
- }
- };
- }}
- #if defined(BOOST_CLANG)
- #pragma clang diagnostic pop
- #endif
- #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
- #pragma GCC diagnostic pop
- #endif
- #endif
|