#ifndef CVD_PIXEL_TRAITS_H_ #define CVD_PIXEL_TRAITS_H_ #include #if defined(CVD_HAVE_TOON) #include #endif namespace CVD { namespace Pixel { template struct traits { static_assert(std::numeric_limits::is_specialized == true, "Traits not defined for this type"); using element_type = T; using wider_type = decltype(T {} * T {}); typedef float float_type; static const bool integral = true; static const bool is_signed = std::numeric_limits::is_signed; static_assert(std::numeric_limits::is_integer == true, "Library bug, we shouldn't be here"); static const int bits_used = std::numeric_limits::digits; static const T max_intensity = std::numeric_limits::max(); }; template struct traits { using element_type = float; typedef float wider_type; typedef float float_type; static const bool integral = false; static const bool is_signed = true; static const float max_intensity; }; template const float traits::max_intensity = 1.0f; template struct traits { using element_type = double; typedef double wider_type; typedef double float_type; static const bool integral = false; static const bool is_signed = true; static const double max_intensity; }; template const double traits::max_intensity = 1.0; template struct traits { using element_type = long double; typedef long double wider_type; typedef long double float_type; static const bool integral = false; static const bool is_signed = true; static const long double max_intensity; }; #if defined(CVD_HAVE_TOON) template struct traits> { typedef TooN::Vector wider_type; typedef TooN::Vector float_type; static const bool integral = false; static const bool is_signed = true; static const TooN::Vector max_intensity; }; template const TooN::Vector traits>::max_intensity = TooN::Vector(1.0); template struct traits> { typedef TooN::Matrix wider_type; typedef TooN::Matrix float_type; static const bool integral = false; static const bool is_signed = true; }; #endif template const long double traits::max_intensity = 1.0; template struct indirect_type { typedef C type; }; template struct traits { typedef typename indirect_type::wider_type[N]>::type wider_type; typedef typename indirect_type::float_type[N]>::type float_type; }; } } #endif