Is decltype really buggy in Visual Studio 2012 or is it actually supposed to be this hard to use?
Example:
namespace ptl
{
struct Test
{
Test(float ){}
};
template<class T, class A0>
static T* static_constructor(void* p, A0 a0){return new(p) T(a0);}
template<class T>
T* MakeVS2012Happy(T*);
}
inline auto ExampleFxn() -> decltype(ptl::MakeVS2012Happy(&ptl::static_constructor<ptl::Test, float>))
{
return &ptl::static_constructor<ptl::Test, float>;
}
inline auto ExampleFxn2() -> decltype(&ptl::static_constructor<ptl::Test, float>)
{
return &ptl::static_constructor<ptl::Test, float>;
}
ExampleFxn compiles because I've wrapped the code in the decltype with that pointless function.
ExampleFxn2 does not, VS2012 spits out the extremely helpful error message:
error C3555: incorrect argument to 'decltype'
Anyone know what causes this? I seem to constantly have to fight against decltype to get it to work as expected...
Thanks