Your problem appears to be with boost::function - the following specialisations work:
template
T safeGuiCall()
{
return T();
}
template <>
void safeGuiCall()
{
}
int main() {
int x = safeGuiCall(); // ok
//int z = safeGuiCall(); // this should & does fail
safeGuiCall(); // ok
}