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/mpl/at.hpp> 12 #include <boost/mpl/size.hpp> 16 namespace boost {
namespace gil {
20 #define GIL_AT_C_VALUE(z, N, text) mpl::at_c<IntTypes,S+N>::type::value, 21 #define GIL_DYNAMIC_AT_C_LIMIT 226 // size of the maximum vector to handle 23 #define GIL_AT_C_LOOKUP(z, NUM, text) \ 24 template<std::size_t S> \ 25 struct at_c_fn<S,NUM> { \ 26 template <typename IntTypes, typename ValueType> inline \ 27 static ValueType apply(std::size_t index) { \ 28 static ValueType table[] = { \ 29 BOOST_PP_REPEAT(NUM, GIL_AT_C_VALUE, BOOST_PP_EMPTY) \ 31 return table[index]; \ 37 template <std::
size_t START, std::
size_t NUM>
struct at_c_fn;
38 BOOST_PP_REPEAT(GIL_DYNAMIC_AT_C_LIMIT, GIL_AT_C_LOOKUP, BOOST_PP_EMPTY)
40 template <std::
size_t QUOT>
struct at_c_impl;
44 template <
typename IntTypes,
typename ValueType>
inline 45 static ValueType apply(std::size_t index) {
46 return at_c_fn<0,mpl::size<IntTypes>::value>::template apply<IntTypes,ValueType>(index);
52 template <
typename IntTypes,
typename ValueType>
inline 53 static ValueType apply(std::size_t index) {
54 const std::size_t SIZE=mpl::size<IntTypes>::value;
55 const std::size_t REM = SIZE % GIL_DYNAMIC_AT_C_LIMIT;
56 switch (index / GIL_DYNAMIC_AT_C_LIMIT) {
57 case 0:
return at_c_fn<0 ,GIL_DYNAMIC_AT_C_LIMIT-1>::template apply<IntTypes,ValueType>(index);
58 case 1:
return at_c_fn<GIL_DYNAMIC_AT_C_LIMIT ,REM >::template apply<IntTypes,ValueType>(index - GIL_DYNAMIC_AT_C_LIMIT);
66 template <
typename IntTypes,
typename ValueType>
inline 67 static ValueType apply(std::size_t index) {
68 const std::size_t SIZE=mpl::size<IntTypes>::value;
69 const std::size_t REM = SIZE % GIL_DYNAMIC_AT_C_LIMIT;
70 switch (index / GIL_DYNAMIC_AT_C_LIMIT) {
71 case 0:
return at_c_fn<0 ,GIL_DYNAMIC_AT_C_LIMIT-1>::template apply<IntTypes,ValueType>(index);
72 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);
73 case 2:
return at_c_fn<GIL_DYNAMIC_AT_C_LIMIT*2,REM >::template apply<IntTypes,ValueType>(index - GIL_DYNAMIC_AT_C_LIMIT*2);
81 template <
typename IntTypes,
typename ValueType>
inline 82 static ValueType apply(std::size_t index) {
83 const std::size_t SIZE=mpl::size<IntTypes>::value;
84 const std::size_t REM = SIZE % GIL_DYNAMIC_AT_C_LIMIT;
85 switch (index / GIL_DYNAMIC_AT_C_LIMIT) {
86 case 0:
return at_c_fn<0 ,GIL_DYNAMIC_AT_C_LIMIT-1>::template apply<IntTypes,ValueType>(index);
87 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);
88 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);
89 case 3:
return at_c_fn<GIL_DYNAMIC_AT_C_LIMIT*3,REM >::template apply<IntTypes,ValueType>(index - GIL_DYNAMIC_AT_C_LIMIT*3);
104 template <
typename IntTypes,
typename ValueType>
inline 105 ValueType
at_c(std::size_t index) {
106 const std::size_t Size=mpl::size<IntTypes>::value;
107 return detail::at_c::at_c_impl<Size/GIL_DYNAMIC_AT_C_LIMIT>::template apply<IntTypes,ValueType>(index);
110 #undef GIL_AT_C_VALUE 111 #undef GIL_DYNAMIC_AT_C_LIMIT 112 #undef GIL_AT_C_LOOKUP Definition: algorithm.hpp:30
add_reference< E >::type at_c(detail::homogeneous_color_base< E, L, N > &p)
Provides mutable access to the K-th element, in physical order.
Definition: color_base.hpp:387