This is about as simplified as I could make a toy example that still hit the bug:
struct Vector3f64 {
double x;
double y;
double z;
};
struct Vector3f32 {
As workaround, you might simply do:
template <typename T>
auto func(const T& dir)
-> decltype(VectorVolume(dir.x, dir.y, dir.z))
{
return VectorVolume(dir.x, dir.y, dir.z);
}
You're really only interested in the function::result_type
so there's really no need to go through the bugged path of returning a function
. Just return the result type and do a decltype on that (you don't even need to define the function since you're not actually calling it.) Something like this:
template <typename R, typename... ARGS>
R make_func(R(*)(ARGS...));
Then just directly use the return type:
template <typename T>
decltype(make_func(&VectorVolume<param_vector<T>>)) func(const T& dir) {
return VectorVolume(dir.x, dir.y, dir.z);
}
This is works great on Visual Studio 15.6.7 and as an added bonus is fully c++14 compatible: https://ideone.com/gcYo8x