While working on fractional BesselK, I am having pains to properly compile templated functions for both `double`

and `var`

template params. A simplified example:

```
namespace stan {
namespace math {
template <typename T>
T test(const T& x) {
return fabs(x);
}
double xx() {
return test<double>(5);
}
}
}
```

gets me:

```
./stan/math/rev/arr/fun/imports_debug.hpp: In instantiation of 'T stan::math::test(const T&) [with T = double]':
./stan/math/rev/arr/fun/imports_debug.hpp:15:26: required from here
./stan/math/rev/arr/fun/imports_debug.hpp:10:20: error: cannot convert 'stan::math::var' to 'double' in return
return fabs(x);
```

However, changing `fabs`

to `exp`

works. Additionally, if I add

```
namespace stan {
namespace math {
double fabs(double x) {
return std::fabs(x);
}
}
}
```

It compiles once again.

My conclusion is that this happens only for functions where `stan::math`

does not contain the double version (e.g. `fabs`

, `pow`

), but not for functions where `stan::math`

contains the double version (e.g. `log`

, `exp`

).

So my question is: why some functions have a double version in `stan::math`

and some do not? And is there a â€ścorrectâ€ť solution that will let me use templating to write both `double`

and `var`

versions of a function using `fabs`

or `pow`

?

**EDIT:** I am on Windows using gcc 4.7.0 as supplied with RTools.