5 # ifndef VCCC_TYPE_SUPPORT_CAST_HPP
6 # define VCCC_TYPE_SUPPORT_CAST_HPP
15 namespace type_support {
17 template<
typename To,
typename From,
typename =
void>
18 struct saturate_cast_possible :
19 # if VCCC_USE_OPENCV_FEATURES
20 public std::integral_constant<bool, are_arithmetic<std::decay_t<To>, std::decay_t<From>>::value>
22 public std::false_type
26 template<
typename To,
typename From>
27 using saturate_cast_possible_t =
typename saturate_cast_possible<To, From>::type;
29 template<
typename To,
typename From>
32 cast(
std::false_type, From&& from) {
33 return static_cast<To
>(std::forward<From>(from));
36 template<
typename To,
typename From>
39 cast(
std::true_type, From from) {
40 # if VCCC_USE_OPENCV_FEATURES
41 return cv::saturate_cast<To>(from);
43 cast(std::false_type{}, from);
51 template<
typename ToType,
typename FromType>
55 return internal::type_support::cast<ToType>(
56 internal::type_support::saturate_cast_possible_t<ToType, FromType>{},
57 std::forward<FromType>(from));
Definition: matrix.hpp:495
Definition: directory.h:12
constexpr decltype(auto) cast(FromType &&from)
Definition: cast.hpp:54