Hi Jeffrey,
Is there any way to get type deduction working on a snippet like lousy_attempt (below) to produce my desired_result?
template<typename Scalar> typename boost::call_traits<Scalar>::value_type lousy_attempt(typename boost::call_traits<Scalar>::param_type x) { return x; }
int main() { double y = 5;
// Works... lousy_attempt<double>(y);
// "No matching function call to lousy_attempt(double&)" lousy_attempt(y);
return 0; }
What you're doing can't work, as the compiler cannot deduce a template parameter based on matching to a nested type.
Ah.
If you really want this effect, you can use Boost.EnableIf...
That snippet was a drastically simplified version of some large code. The enable_if mechanism makes sense but will be a painful burden.
But I would generally recommend to just use T const &.
I'll keep with your recommendation. Thank you for the excellent explanation, Rhys