8 #ifndef BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_DYNAMIC_AT_C_HPP
9 #define BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_DYNAMIC_AT_C_HPP
11 #include <boost/gil/detail/mp11.hpp>
13 #include <boost/preprocessor/facilities/empty.hpp>
14 #include <boost/preprocessor/repetition/repeat.hpp>
18 namespace boost {
namespace gil {
22 #define BOOST_GIL_AT_C_VALUE(z, N, text) mp11::mp_at_c<IntTypes, S+N>::value,
23 #define BOOST_GIL_DYNAMIC_AT_C_LIMIT 226
25 #define BOOST_GIL_AT_C_LOOKUP(z, NUM, text) \
26 template<std::size_t S> \
27 struct at_c_fn<S,NUM> { \
28 template <typename IntTypes, typename ValueType> inline \
29 static ValueType apply(std::size_t index) { \
30 static ValueType table[] = { \
31 BOOST_PP_REPEAT(NUM, BOOST_GIL_AT_C_VALUE, BOOST_PP_EMPTY) \
33 return table[index]; \
39 template <std::
size_t START, std::
size_t NUM>
struct at_c_fn;
40 BOOST_PP_REPEAT(BOOST_GIL_DYNAMIC_AT_C_LIMIT, BOOST_GIL_AT_C_LOOKUP, BOOST_PP_EMPTY)
42 template <std::
size_t QUOT>
struct at_c_impl;
46 template <
typename IntTypes,
typename ValueType>
inline
47 static ValueType apply(std::size_t index) {
48 return at_c_fn<0, mp11::mp_size<IntTypes>::value>::template apply<IntTypes,ValueType>(index);
54 template <
typename IntTypes,
typename ValueType>
inline
55 static ValueType apply(std::size_t index) {
56 const std::size_t SIZE = mp11::mp_size<IntTypes>::value;
57 const std::size_t REM = SIZE % BOOST_GIL_DYNAMIC_AT_C_LIMIT;
58 switch (index / BOOST_GIL_DYNAMIC_AT_C_LIMIT) {
59 case 0:
return at_c_fn<0 ,BOOST_GIL_DYNAMIC_AT_C_LIMIT-1>::template apply<IntTypes,ValueType>(index);
60 case 1:
return at_c_fn<BOOST_GIL_DYNAMIC_AT_C_LIMIT ,REM >::template apply<IntTypes,ValueType>(index - BOOST_GIL_DYNAMIC_AT_C_LIMIT);
68 template <
typename IntTypes,
typename ValueType>
inline
69 static ValueType apply(std::size_t index) {
70 const std::size_t SIZE = mp11::mp_size<IntTypes>::value;
71 const std::size_t REM = SIZE % BOOST_GIL_DYNAMIC_AT_C_LIMIT;
72 switch (index / BOOST_GIL_DYNAMIC_AT_C_LIMIT) {
73 case 0:
return at_c_fn<0 ,BOOST_GIL_DYNAMIC_AT_C_LIMIT-1>::template apply<IntTypes,ValueType>(index);
74 case 1:
return at_c_fn<BOOST_GIL_DYNAMIC_AT_C_LIMIT ,BOOST_GIL_DYNAMIC_AT_C_LIMIT-1>::template apply<IntTypes,ValueType>(index - BOOST_GIL_DYNAMIC_AT_C_LIMIT);
75 case 2:
return at_c_fn<BOOST_GIL_DYNAMIC_AT_C_LIMIT*2,REM >::template apply<IntTypes,ValueType>(index - BOOST_GIL_DYNAMIC_AT_C_LIMIT*2);
83 template <
typename IntTypes,
typename ValueType>
inline
84 static ValueType apply(std::size_t index) {
85 const std::size_t SIZE = mp11::mp_size<IntTypes>::value;
86 const std::size_t REM = SIZE % BOOST_GIL_DYNAMIC_AT_C_LIMIT;
87 switch (index / BOOST_GIL_DYNAMIC_AT_C_LIMIT) {
88 case 0:
return at_c_fn<0 ,BOOST_GIL_DYNAMIC_AT_C_LIMIT-1>::template apply<IntTypes,ValueType>(index);
89 case 1:
return at_c_fn<BOOST_GIL_DYNAMIC_AT_C_LIMIT ,BOOST_GIL_DYNAMIC_AT_C_LIMIT-1>::template apply<IntTypes,ValueType>(index - BOOST_GIL_DYNAMIC_AT_C_LIMIT);
90 case 2:
return at_c_fn<BOOST_GIL_DYNAMIC_AT_C_LIMIT*2,BOOST_GIL_DYNAMIC_AT_C_LIMIT-1>::template apply<IntTypes,ValueType>(index - BOOST_GIL_DYNAMIC_AT_C_LIMIT*2);
91 case 3:
return at_c_fn<BOOST_GIL_DYNAMIC_AT_C_LIMIT*3,REM >::template apply<IntTypes,ValueType>(index - BOOST_GIL_DYNAMIC_AT_C_LIMIT*3);
107 template <
typename IntTypes,
typename ValueType>
inline
108 ValueType
at_c(std::size_t index) {
109 const std::size_t Size=mp11::mp_size<IntTypes>::value;
110 return detail::at_c::at_c_impl<Size/BOOST_GIL_DYNAMIC_AT_C_LIMIT>::template apply<IntTypes,ValueType>(index);
113 #undef BOOST_GIL_AT_C_VALUE
114 #undef BOOST_GIL_DYNAMIC_AT_C_LIMIT
115 #undef BOOST_GIL_AT_C_LOOKUP
auto at_c(detail::homogeneous_color_base< E, L, N > &p) -> typename std::add_lvalue_reference< E >::type
Provides mutable access to the K-th element, in physical order.
Definition: color_base.hpp:632
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36