VS2010 doesn't implement decltype
exactly as the standard specifies (to be fair, it's older than the final version of the standard). You should be able to get around this with hand-coded declval
:
template < typename A >
class X
{
A& m_a;
static A& simulated_m_a();
public:
X ( A& a ) : m_a ( a ) {}
auto func ( int i ) -> decltype ( simulated_m_a()( i ) ) { return ( m_a ( i ) ); }
};
I've just verified on my VS2010 that it works.