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 GIL_AT_C_VALUE(z, N, text) mp11::mp_at_c<IntTypes, S+N>::value,    23 #define GIL_DYNAMIC_AT_C_LIMIT 226 // size of the maximum vector to handle    25 #define 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, 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(GIL_DYNAMIC_AT_C_LIMIT, 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 % GIL_DYNAMIC_AT_C_LIMIT;
    58                 switch (index / GIL_DYNAMIC_AT_C_LIMIT) {
    59                     case 0: 
return at_c_fn<0                   ,GIL_DYNAMIC_AT_C_LIMIT-1>::template apply<IntTypes,ValueType>(index);
    60                     case 1: 
return at_c_fn<GIL_DYNAMIC_AT_C_LIMIT  ,REM                 >::template apply<IntTypes,ValueType>(index - 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 % GIL_DYNAMIC_AT_C_LIMIT;
    72                 switch (index / GIL_DYNAMIC_AT_C_LIMIT) {
    73                     case 0: 
return at_c_fn<0                   ,GIL_DYNAMIC_AT_C_LIMIT-1>::template apply<IntTypes,ValueType>(index);
    74                     case 1: 
return at_c_fn<GIL_DYNAMIC_AT_C_LIMIT  ,GIL_DYNAMIC_AT_C_LIMIT-1>::template apply<IntTypes,ValueType>(index - GIL_DYNAMIC_AT_C_LIMIT);
    75                     case 2: 
return at_c_fn<GIL_DYNAMIC_AT_C_LIMIT*2,REM                 >::template apply<IntTypes,ValueType>(index - 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 % GIL_DYNAMIC_AT_C_LIMIT;
    87                 switch (index / GIL_DYNAMIC_AT_C_LIMIT) {
    88                     case 0: 
return at_c_fn<0                   ,GIL_DYNAMIC_AT_C_LIMIT-1>::template apply<IntTypes,ValueType>(index);
    89                     case 1: 
return at_c_fn<GIL_DYNAMIC_AT_C_LIMIT  ,GIL_DYNAMIC_AT_C_LIMIT-1>::template apply<IntTypes,ValueType>(index - GIL_DYNAMIC_AT_C_LIMIT);
    90                     case 2: 
return at_c_fn<GIL_DYNAMIC_AT_C_LIMIT*2,GIL_DYNAMIC_AT_C_LIMIT-1>::template apply<IntTypes,ValueType>(index - GIL_DYNAMIC_AT_C_LIMIT*2);
    91                     case 3: 
return at_c_fn<GIL_DYNAMIC_AT_C_LIMIT*3,REM                 >::template apply<IntTypes,ValueType>(index - 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/GIL_DYNAMIC_AT_C_LIMIT>::template apply<IntTypes,ValueType>(index);
   113 #undef GIL_AT_C_VALUE   114 #undef GIL_DYNAMIC_AT_C_LIMIT   115 #undef 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:597