Boost logo

Boost Users :

Subject: [Boost-users] [call_traits] Having trouble with call traits combined with type deduction
From: Rhys Ulerich (rhys.ulerich_at_[hidden])
Date: 2011-12-16 17:46:31


'Afternoon,

I have a quick question on call traits and template argument
deduction. I want to use call_traits' value_type and param_type to
deduce a signature like
  double desired_result(double const& x);
given an argument of type double.

Is there any way to get type deduction working on a snippet like
lousy_attempt (below) to produce my desired_result?

#include <boost/call_traits.hpp>

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;
}

Thanks in advance,
Rhys


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net