File indexing completed on 2025-01-18 09:36:55
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_GIL_CONCEPTS_PIXEL_ITERATOR_HPP
0009 #define BOOST_GIL_CONCEPTS_PIXEL_ITERATOR_HPP
0010
0011 #include <boost/gil/concepts/channel.hpp>
0012 #include <boost/gil/concepts/color.hpp>
0013 #include <boost/gil/concepts/concept_check.hpp>
0014 #include <boost/gil/concepts/fwd.hpp>
0015 #include <boost/gil/concepts/pixel.hpp>
0016 #include <boost/gil/concepts/pixel_based.hpp>
0017
0018 #include <boost/iterator/iterator_concepts.hpp>
0019
0020 #include <cstddef>
0021 #include <iterator>
0022 #include <type_traits>
0023
0024 #if defined(BOOST_CLANG)
0025 #pragma clang diagnostic push
0026 #pragma clang diagnostic ignored "-Wunknown-pragmas"
0027 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
0028 #endif
0029
0030 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0031 #pragma GCC diagnostic push
0032 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
0033 #endif
0034
0035 namespace boost { namespace gil {
0036
0037
0038 template <typename It> struct const_iterator_type;
0039 template <typename It> struct iterator_is_mutable;
0040 template <typename It> struct is_iterator_adaptor;
0041 template <typename It, typename NewBaseIt> struct iterator_adaptor_rebind;
0042 template <typename It> struct iterator_adaptor_get_base;
0043
0044
0045
0046 namespace detail {
0047
0048
0049 template <class TT>
0050 struct ForwardIteratorIsMutableConcept
0051 {
0052 void constraints()
0053 {
0054 auto const tmp = *i;
0055 *i++ = tmp;
0056 }
0057 TT i;
0058 };
0059
0060
0061 template <class TT>
0062 struct BidirectionalIteratorIsMutableConcept
0063 {
0064 void constraints()
0065 {
0066 gil_function_requires< ForwardIteratorIsMutableConcept<TT>>();
0067 auto const tmp = *i;
0068 *i-- = tmp;
0069 }
0070 TT i;
0071 };
0072
0073
0074 template <class TT>
0075 struct RandomAccessIteratorIsMutableConcept
0076 {
0077 void constraints()
0078 {
0079 gil_function_requires<BidirectionalIteratorIsMutableConcept<TT>>();
0080
0081 typename std::iterator_traits<TT>::difference_type n = 0;
0082 ignore_unused_variable_warning(n);
0083 i[n] = *i;
0084 }
0085 TT i;
0086 };
0087
0088
0089
0090 template <typename Iterator>
0091 struct RandomAccessIteratorIsMemoryBasedConcept
0092 {
0093 void constraints()
0094 {
0095 std::ptrdiff_t bs = memunit_step(it);
0096 ignore_unused_variable_warning(bs);
0097
0098 it = memunit_advanced(it, 3);
0099 std::ptrdiff_t bd = memunit_distance(it, it);
0100 ignore_unused_variable_warning(bd);
0101
0102 memunit_advance(it,3);
0103
0104 }
0105 Iterator it;
0106 };
0107
0108
0109 template <typename Iterator>
0110 struct PixelIteratorIsMutableConcept
0111 {
0112 void constraints()
0113 {
0114 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<Iterator>>();
0115
0116 using ref_t = typename std::remove_reference
0117 <
0118 typename std::iterator_traits<Iterator>::reference
0119 >::type;
0120 using channel_t = typename element_type<ref_t>::type;
0121 gil_function_requires<detail::ChannelIsMutableConcept<channel_t>>();
0122 }
0123 };
0124
0125 }
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136 template <typename T>
0137 struct HasTransposedTypeConcept
0138 {
0139 void constraints()
0140 {
0141 using type = typename transposed_type<T>::type;
0142 ignore_unused_variable_warning(type{});
0143 }
0144 };
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169 template <typename Iterator>
0170 struct PixelIteratorConcept
0171 {
0172 void constraints()
0173 {
0174 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<Iterator>>();
0175 gil_function_requires<PixelBasedConcept<Iterator>>();
0176
0177 using value_type = typename std::iterator_traits<Iterator>::value_type;
0178 gil_function_requires<PixelValueConcept<value_type>>();
0179
0180 using const_t = typename const_iterator_type<Iterator>::type;
0181 static bool const is_mutable = iterator_is_mutable<Iterator>::value;
0182 ignore_unused_variable_warning(is_mutable);
0183
0184
0185 const_t const_it(it);
0186 ignore_unused_variable_warning(const_it);
0187
0188 check_base(typename is_iterator_adaptor<Iterator>::type());
0189 }
0190
0191 void check_base(std::false_type) {}
0192
0193 void check_base(std::true_type)
0194 {
0195 using base_t = typename iterator_adaptor_get_base<Iterator>::type;
0196 gil_function_requires<PixelIteratorConcept<base_t>>();
0197 }
0198
0199 Iterator it;
0200 };
0201
0202
0203
0204
0205
0206
0207
0208 template <typename Iterator>
0209 struct MutablePixelIteratorConcept
0210 {
0211 void constraints()
0212 {
0213 gil_function_requires<PixelIteratorConcept<Iterator>>();
0214 gil_function_requires<detail::PixelIteratorIsMutableConcept<Iterator>>();
0215 }
0216 };
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235 template <typename Iterator>
0236 struct MemoryBasedIteratorConcept
0237 {
0238 void constraints()
0239 {
0240 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<Iterator>>();
0241 gil_function_requires<detail::RandomAccessIteratorIsMemoryBasedConcept<Iterator>>();
0242 }
0243 };
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256 template <typename Iterator>
0257 struct StepIteratorConcept
0258 {
0259 void constraints()
0260 {
0261 gil_function_requires<boost_concepts::ForwardTraversalConcept<Iterator>>();
0262 it.set_step(0);
0263 }
0264 Iterator it;
0265 };
0266
0267
0268
0269
0270
0271
0272
0273
0274 template <typename Iterator>
0275 struct MutableStepIteratorConcept
0276 {
0277 void constraints()
0278 {
0279 gil_function_requires<StepIteratorConcept<Iterator>>();
0280 gil_function_requires<detail::ForwardIteratorIsMutableConcept<Iterator>>();
0281 }
0282 };
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316 template <typename Iterator>
0317 struct IteratorAdaptorConcept
0318 {
0319 void constraints()
0320 {
0321 gil_function_requires<boost_concepts::ForwardTraversalConcept<Iterator>>();
0322
0323 using base_t = typename iterator_adaptor_get_base<Iterator>::type;
0324 gil_function_requires<boost_concepts::ForwardTraversalConcept<base_t>>();
0325
0326 static_assert(is_iterator_adaptor<Iterator>::value, "");
0327 using rebind_t = typename iterator_adaptor_rebind<Iterator, void*>::type;
0328
0329 base_t base = it.base();
0330 ignore_unused_variable_warning(base);
0331 }
0332 Iterator it;
0333 };
0334
0335
0336
0337
0338
0339
0340
0341 template <typename Iterator>
0342 struct MutableIteratorAdaptorConcept
0343 {
0344 void constraints()
0345 {
0346 gil_function_requires<IteratorAdaptorConcept<Iterator>>();
0347 gil_function_requires<detail::ForwardIteratorIsMutableConcept<Iterator>>();
0348 }
0349 };
0350
0351 }}
0352
0353 #if defined(BOOST_CLANG)
0354 #pragma clang diagnostic pop
0355 #endif
0356
0357 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0358 #pragma GCC diagnostic pop
0359 #endif
0360
0361 #endif