Hi Christian,
Thanks for looking over my patch. With a minor amount of tweaking of
your code and my sample program, I was able to compile both my sample
program and my reasonably extensive work code.
The only difference between what you suggested and what I'm posting is
the addition of some explicit construction calls:
Index: channel_algorithm.hpp
===================================================================
--- channel_algorithm.hpp (revision 63088)
+++ channel_algorithm.hpp (working copy)
@@ -250,11 +250,12 @@
template
struct channel_converter_unsigned_integral_nondivisible
{
DstChannelV operator()(SrcChannelV src) const {
- typedef typename
unsigned_integral_max_value<SrcChannelV>::value_type integer_t;
+ typedef typename
unsigned_integral_max_value<SrcChannelV>::value_type src_integer_t;
+ typedef typename
unsigned_integral_max_value<DstChannelV>::value_type dst_integer_t;
static const double div =
unsigned_integral_max_value<SrcChannelV>::value /
double(unsigned_integral_max_value<DstChannelV>::value);
- static const integer_t div2 = integer_t(div/2);
- return DstChannelV((src + div2) / div);
+ static const src_integer_t div2 = static_cast(div/2);
+ return DstChannelV(static_cast((src + div2) / div));
}
};
@@ -265,7 +266,10 @@
/////////////////////////////////////////////////////
template <typename DstChannelV> struct
channel_converter_unsigned : public
std::unary_function {
- DstChannelV operator()(bits32f x) const { return
DstChannelV(x*channel_traits<DstChannelV>::max_value()+0.5f); }
+ DstChannelV operator()(bits32f x) const {
+ typedef typename
detail::unsigned_integral_max_value<DstChannelV>::value_type
dst_integer_t;
+ return DstChannelV(static_cast(x*channel_traits<DstChannelV>::max_value()+0.5f));
+ }
};
template <typename SrcChannelV> struct
channel_converter_unsigned : public
std::unary_function {
My sample program required the following modification:
FROM:
template <>
struct unsigned_integral_max_value<bits14>
: public mpl::integral_c {};
TO:
template <>
struct unsigned_integral_max_value<bits14>
: public mpl::integral_c {};
This makes the specialization of unsigned_integral_max_value different
from the others in channel_algorithm.hpp -- they use uint32_t and
uintmax_t, even for 8 and 16 bit types. This appears to be
intentional, as changing them to match their arguments results in a
compile error (and many tricky const initialization problems). This
makes me wonder if the unsigned_integral_max_value<>::value_type was
intended to be used that way.
I wonder if there's value in a metafunction that returns the type we
expect to construct our channel from (similar to the suggested
base_channel). This isn't a critical issue for me, however, as your
suggestions are working well for me now.
Thanks!
Nate