@@ -757,7 +757,7 @@ scaled_conversion(const S& src, F scale, F min, F max)
757757template <typename S, typename D>
758758void convert_type (const S *src, D *dst, size_t n, D _min, D _max)
759759{
760- if (std::is_same<S,D>::value) {
760+ if constexpr (std::is_same<S,D>::value) {
761761 // They must be the same type. Just memcpy.
762762 memcpy (dst, src, n*sizeof (D));
763763 return ;
@@ -968,6 +968,25 @@ inline void convert_type (const S *src, D *dst, size_t n)
968968
969969
970970
971+ // / Copy (type convert) consecutive values from the cspan `src` holding data
972+ // / of type S into the span `dst` holding the same number of elements of data
973+ // / of type D.
974+ // /
975+ // / The conversion is not a simple cast, but correctly remaps the 0.0->1.0
976+ // / range from and to the full positive range of integral types. It's just a
977+ // / straight copy if both types are identical. Optional arguments `min` and
978+ // / `max` can give nonstandard quantizations.
979+ template <typename S, typename D>
980+ void convert_type (cspan<S> src, span<D> dst,
981+ D min = std::numeric_limits<D>::min(),
982+ D max = std::numeric_limits<D>::min())
983+ {
984+ OIIO_DASSERT (src.size () == dst.size ());
985+ convert_type (src.data (), dst.data (), std::min (src.size (), dst.size ()),
986+ min, max);
987+ }
988+
989+
971990
972991// / Convert a single value from the type of S to the type of D.
973992// / The conversion is not a simple cast, but correctly remaps the
@@ -978,7 +997,7 @@ template<typename S, typename D>
978997inline D
979998convert_type (const S &src)
980999{
981- if (std::is_same<S,D>::value) {
1000+ if constexpr (std::is_same<S,D>::value) {
9821001 // They must be the same type. Just return it.
9831002 return (D)src;
9841003 }
0 commit comments