File indexing completed on 2025-01-18 09:36:54
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_GIL_CONCEPTS_CHANNEL_HPP
0009 #define BOOST_GIL_CONCEPTS_CHANNEL_HPP
0010
0011 #include <boost/gil/concepts/basic.hpp>
0012 #include <boost/gil/concepts/concept_check.hpp>
0013 #include <boost/gil/concepts/fwd.hpp>
0014
0015 #include <boost/concept_check.hpp>
0016
0017 #include <utility> // std::swap
0018 #include <type_traits>
0019
0020 #if defined(BOOST_CLANG)
0021 #pragma clang diagnostic push
0022 #pragma clang diagnostic ignored "-Wunknown-pragmas"
0023 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
0024 #endif
0025
0026 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0027 #pragma GCC diagnostic push
0028 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
0029 #endif
0030
0031 namespace boost { namespace gil {
0032
0033
0034 template <typename T>
0035 struct channel_traits;
0036
0037 template <typename DstT, typename SrcT>
0038 auto channel_convert(SrcT const& val)
0039 -> typename channel_traits<DstT>::value_type;
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073 template <typename T>
0074 struct ChannelConcept
0075 {
0076 void constraints()
0077 {
0078 gil_function_requires<boost::EqualityComparableConcept<T>>();
0079
0080 using v = typename channel_traits<T>::value_type;
0081 using r = typename channel_traits<T>::reference;
0082 using p = typename channel_traits<T>::pointer;
0083 using cr = typename channel_traits<T>::const_reference;
0084 using cp = typename channel_traits<T>::const_pointer;
0085
0086 channel_traits<T>::min_value();
0087 channel_traits<T>::max_value();
0088 }
0089
0090 T c;
0091 };
0092
0093 namespace detail
0094 {
0095
0096
0097 template <typename T>
0098 struct ChannelIsMutableConcept
0099 {
0100 void constraints()
0101 {
0102 c1 = c2;
0103 using std::swap;
0104 swap(c1, c2);
0105 }
0106 T c1;
0107 T c2;
0108 };
0109
0110 }
0111
0112
0113
0114
0115
0116
0117 template <typename T>
0118 struct MutableChannelConcept
0119 {
0120 void constraints()
0121 {
0122 gil_function_requires<ChannelConcept<T>>();
0123 gil_function_requires<detail::ChannelIsMutableConcept<T>>();
0124 }
0125 };
0126
0127
0128
0129
0130
0131
0132 template <typename T>
0133 struct ChannelValueConcept
0134 {
0135 void constraints()
0136 {
0137 gil_function_requires<ChannelConcept<T>>();
0138 gil_function_requires<Regular<T>>();
0139 }
0140 };
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153 template <typename T1, typename T2>
0154 struct channels_are_compatible
0155 : std::is_same
0156 <
0157 typename channel_traits<T1>::value_type,
0158 typename channel_traits<T2>::value_type
0159 >
0160 {
0161 };
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172 template <typename Channel1, typename Channel2>
0173 struct ChannelsCompatibleConcept
0174 {
0175 void constraints()
0176 {
0177 static_assert(channels_are_compatible<Channel1, Channel2>::value, "");
0178 }
0179 };
0180
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192 template <typename SrcChannel, typename DstChannel>
0193 struct ChannelConvertibleConcept
0194 {
0195 void constraints()
0196 {
0197 gil_function_requires<ChannelConcept<SrcChannel>>();
0198 gil_function_requires<MutableChannelConcept<DstChannel>>();
0199 dst = channel_convert<DstChannel, SrcChannel>(src);
0200 ignore_unused_variable_warning(dst);
0201 }
0202 SrcChannel src;
0203 DstChannel dst;
0204 };
0205
0206 }}
0207
0208 #if defined(BOOST_CLANG)
0209 #pragma clang diagnostic pop
0210 #endif
0211
0212 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0213 #pragma GCC diagnostic pop
0214 #endif
0215
0216 #endif