Type deduction fails for the following case. It compiles if I specify the template argument to someFunc. I definitely see how this is a weird case but it would be nice if I could get it to work. Is there an alternate way to formulate it that would compile without providing the template parameter? A C++17 solution is fine.
#include <type_traits>
template<typename T>
using choose_arg_type = typename std::conditional<std::is_fundamental<T>::value,T,const T &>::type;
template<typename T>
T someFunc(choose_arg_type<T> arg)
{
return arg + arg;
}
int main()
{
auto result = someFunc(0.0);
return 0;
}