File indexing completed on 2025-01-18 09:36:54
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_GIL_CONCEPTS_COLOR_BASE_HPP
0009 #define BOOST_GIL_CONCEPTS_COLOR_BASE_HPP
0010
0011 #include <boost/gil/concepts/basic.hpp>
0012 #include <boost/gil/concepts/color.hpp>
0013 #include <boost/gil/concepts/concept_check.hpp>
0014 #include <boost/gil/concepts/fwd.hpp>
0015
0016 #include <boost/core/ignore_unused.hpp>
0017 #include <type_traits>
0018
0019 #if defined(BOOST_CLANG)
0020 #pragma clang diagnostic push
0021 #pragma clang diagnostic ignored "-Wunknown-pragmas"
0022 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
0023 #endif
0024
0025 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0026 #pragma GCC diagnostic push
0027 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
0028 #endif
0029
0030 namespace boost { namespace gil {
0031
0032
0033 namespace detail {
0034
0035 template <typename Element, typename Layout, int K>
0036 struct homogeneous_color_base;
0037
0038 }
0039
0040 template <int K, typename E, typename L, int N>
0041 auto at_c(detail::homogeneous_color_base<E, L, N>& p)
0042 -> typename std::add_lvalue_reference<E>::type;
0043
0044 template <int K, typename E, typename L, int N>
0045 auto at_c(detail::homogeneous_color_base<E, L, N> const& p)
0046 -> typename std::add_lvalue_reference<typename std::add_const<E>::type>::type;
0047
0048 template <typename P, typename C, typename L>
0049 struct packed_pixel;
0050
0051 template <int K, typename P, typename C, typename L>
0052 auto at_c(packed_pixel<P, C, L>& p)
0053 -> typename kth_element_reference_type<packed_pixel<P, C, L>, K>::type;
0054
0055 template <int K, typename P, typename C, typename L>
0056 auto at_c(packed_pixel<P, C, L> const& p)
0057 -> typename kth_element_const_reference_type<packed_pixel<P, C, L>, K>::type;
0058
0059 template <typename B, typename C, typename L, bool M>
0060 struct bit_aligned_pixel_reference;
0061
0062 template <int K, typename B, typename C, typename L, bool M>
0063 inline auto at_c(bit_aligned_pixel_reference<B, C, L, M> const& p)
0064 -> typename kth_element_reference_type
0065 <
0066 bit_aligned_pixel_reference<B, C, L, M>,
0067 K
0068 >::type;
0069
0070
0071 template <int K, typename ColorBase>
0072 auto semantic_at_c(ColorBase& p)
0073 -> typename std::enable_if
0074 <
0075 !std::is_const<ColorBase>::value,
0076 typename kth_semantic_element_reference_type<ColorBase, K>::type
0077 >::type;
0078
0079 template <int K, typename ColorBase>
0080 auto semantic_at_c(ColorBase const& p)
0081 -> typename kth_semantic_element_const_reference_type<ColorBase, K>::type;
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136 template <typename ColorBase>
0137 struct ColorBaseConcept
0138 {
0139 void constraints()
0140 {
0141 gil_function_requires<CopyConstructible<ColorBase>>();
0142 gil_function_requires<EqualityComparable<ColorBase>>();
0143
0144 using color_space_t = typename ColorBase::layout_t::color_space_t;
0145 gil_function_requires<ColorSpaceConcept<color_space_t>>();
0146
0147 using channel_mapping_t = typename ColorBase::layout_t::channel_mapping_t;
0148
0149
0150 static const int num_elements = size<ColorBase>::value;
0151
0152 using TN = typename kth_element_type<ColorBase, num_elements - 1>::type;
0153 using RN = typename kth_element_const_reference_type<ColorBase, num_elements - 1>::type;
0154
0155 RN r = gil::at_c<num_elements - 1>(cb);
0156 boost::ignore_unused(r);
0157
0158
0159 semantic_at_c<0>(cb);
0160 semantic_at_c<num_elements-1>(cb);
0161
0162
0163 }
0164 ColorBase cb;
0165 };
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182 template <typename ColorBase>
0183 struct MutableColorBaseConcept
0184 {
0185 void constraints()
0186 {
0187 gil_function_requires<ColorBaseConcept<ColorBase>>();
0188 gil_function_requires<Assignable<ColorBase>>();
0189 gil_function_requires<Swappable<ColorBase>>();
0190
0191 using R0 = typename kth_element_reference_type<ColorBase, 0>::type;
0192
0193 R0 r = gil::at_c<0>(cb);
0194 gil::at_c<0>(cb) = r;
0195 }
0196 ColorBase cb;
0197 };
0198
0199
0200
0201
0202
0203
0204
0205
0206 template <typename ColorBase>
0207 struct ColorBaseValueConcept
0208 {
0209 void constraints()
0210 {
0211 gil_function_requires<MutableColorBaseConcept<ColorBase>>();
0212 gil_function_requires<Regular<ColorBase>>();
0213 }
0214 };
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226 template <typename ColorBase>
0227 struct HomogeneousColorBaseConcept
0228 {
0229 void constraints()
0230 {
0231 gil_function_requires<ColorBaseConcept<ColorBase>>();
0232
0233 static const int num_elements = size<ColorBase>::value;
0234
0235 using T0 = typename kth_element_type<ColorBase, 0>::type;
0236 using TN = typename kth_element_type<ColorBase, num_elements - 1>::type;
0237
0238 static_assert(std::is_same<T0, TN>::value, "");
0239
0240 using R0 = typename kth_element_const_reference_type<ColorBase, 0>::type;
0241 R0 r = dynamic_at_c(cb, 0);
0242 boost::ignore_unused(r);
0243 }
0244 ColorBase cb;
0245 };
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256 template <typename ColorBase>
0257 struct MutableHomogeneousColorBaseConcept
0258 {
0259 void constraints()
0260 {
0261 gil_function_requires<ColorBaseConcept<ColorBase>>();
0262 gil_function_requires<HomogeneousColorBaseConcept<ColorBase>>();
0263 using R0 = typename kth_element_reference_type<ColorBase, 0>::type;
0264 R0 r = dynamic_at_c(cb, 0);
0265 boost::ignore_unused(r);
0266 dynamic_at_c(cb, 0) = dynamic_at_c(cb, 0);
0267 }
0268 ColorBase cb;
0269 };
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281 template <typename ColorBase>
0282 struct HomogeneousColorBaseValueConcept
0283 {
0284 void constraints()
0285 {
0286 gil_function_requires<MutableHomogeneousColorBaseConcept<ColorBase>>();
0287 gil_function_requires<Regular<ColorBase>>();
0288 }
0289 };
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302 template <typename ColorBase1, typename ColorBase2>
0303 struct ColorBasesCompatibleConcept
0304 {
0305 void constraints()
0306 {
0307 static_assert(std::is_same
0308 <
0309 typename ColorBase1::layout_t::color_space_t,
0310 typename ColorBase2::layout_t::color_space_t
0311 >::value, "");
0312
0313
0314
0315
0316 }
0317 };
0318
0319 }}
0320
0321 #if defined(BOOST_CLANG)
0322 #pragma clang diagnostic pop
0323 #endif
0324
0325 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0326 #pragma GCC diagnostic pop
0327 #endif
0328
0329 #endif