我有一个以 为模板的类<PIXEL>,假定是boost::gil的像素类型之一(目前,只有一个gray8_pixel_t或gray16_pixel_t,并且我只希望支持同质像素类型rgb8_pixel_t,例如将来)。
该类需要掌握unsigned char或unsigned short适合像素类型;我认为这被埋在像素类中,但没有一个PIXEL::value_type,PIXEL::channel_type或者PIXEL::channel_type::value type似乎是我想要的。
有什么诀窍?
(我当然可以通过一些模板专用的辅助结构使用类型间接来获取此信息:
template <typename PIXEL> struct types_for
{};
template <> struct types_for<boost::gil::gray8_pixel_t>
{typedef unsigned char channel_type;};
template <> struct types_for<boost::gil::gray16_pixel_t>
{typedef unsigned short channel_type;};
但如果我能找到它,GIL 肯定已经提供了等价的东西......)