I want to use a default argument that is initialized with a static member function. I have the following example :
//A.h
#include <string>
class A
{
public:
template<class T>
static T& Get(const std::wstring&);
};
//Util.h
#include "A.h"
#include <string>
class B
{
public:
void f(
double d,
double c = A::Get<double>(L"test"));
}
//main.cpp
#include "Util.h"
int main()
{
B b;
b.f(5);
}
The error I am getting is
util.h(7): error C2783: 'T &A::Get(const std::wstring &)' : could not deduce template argument for 'T'.
I can't get why this does not compile.
EDIT: I am using visual studio 2010 sp1. And it seem this is compiler bug. If I change Get to be global and not static member of A, it compiles.