Is decltype really buggy in Visual Studio 2012 or is it actually supposed to be this hard to use?
Example:
namespace ptl
{
struct Test
{
I agree with Dietmar: This is a bug in the compiler. The issue appears to be that decltype
cannot be applied to an expression that takes the address of a function template specialization. That is, the following is a minimal repro for this issue:
template <typename>
void f();
typedef decltype(&f<void>) t;
As a workaround, consider applying decltype
to the function template specialization directly, then adding *
to form the required pointer type:
inline auto ExampleFxn2()
-> decltype(ptl::static_constructor<ptl::Test, float>)*
{
return &ptl::static_constructor<ptl::Test, float>;
}
Please consider opening a bug for this on Microsoft Connect and posting a link as a comment here for future readers (or, if you would prefer not to, let me know and I would be happy to open a bug for this issue).
The type of &ptl::static_constructor<ptl::Test, float>
can be deduced by decltype()
. This looks like a bug in MSVC++. Both clang and gcc agree that the code is fine (assuming #include <new>
is added).