I'm trying to invoke a template function from inside another template, and the C++ compiler is getting confused trying to parse my code.
Basically what's happening is it can't tell that my function is a template function. It thinks it's a field, so it's interpreting the template open brace "<" for a less than operator.
const size_t chiR = tindexR::value;
auto chR = helpers::convert_channel_depth<tchR,trchR>(channel_unchecked<chiR>());
result->channel_unchecked<chiR>(chR)
It shouldn't matter, but for context, here's the function definition (it's inside a class)
template<size_t Index>
constexpr inline void channel_unchecked(typename channel_by_index_or_empty<Index>::int_type value) {
if(0>Index || Index>=channels) return;
using ch = channel_by_index_or_empty<Index>;
const typename ch::pixel_type::int_type shval = typename ch::pixel_type::int_type(helpers::order_guard((value<ch::min)?ch::min:(value>ch::max)?ch::max:value))<<ch::bits_to_right;
be_value=(be_value&~ch::channel_mask)|shval;
}
I've had something similar happen before calling derived virtual functions when the base class is a template, which I could do simply force by preceding the call with
this->
but I don't know how to make the C++ compiler do the right thing *here*
So my question is, how do I force the C++ compiler to interpret the line above as a function rather than a field?
What I have tried:
Here's my current workaround. Instead of calling the function, I've reimplemented it:
const size_t chiR = tindexR::value;
auto chR = helpers::convert_channel_depth<tchR,trchR>(channel_unchecked<chiR>());
const typename PixelTypeRhs::int_type shvalR =
typename PixelTypeRhs::int_type(helpers::order_guard((chR<trchR::min)?trchR::min:(chR>trchR::max)?trchR::max:chR))<<trchR::bits_to_right;
be_value=(be_value&~trchR::channel_mask)|shvalR;
This is undesirable, obviously.