Why does the following not compile:
typedef int Table;
class FullObjId
{
public:
explicit FullObjId( const Table* i ) {}
};
class TableInfo
{
public:
TableInfo( const FullObjId& o ) {}
bool isValid() { return true; }
};
void dataSourceForHist( const Table& table )
{
// The next line gives an error
TableInfo tableInfo( FullObjId( &table ) );
// Unless it's written like this:
//TableInfo tableInfo( ( FullObjId( &table ) ) );
if (!tableInfo.isValid())
{
...
}
}
I have tried with the Intel Compiler 12.1 for Linux, and using http://gcc.godbolt.org/ with g++ 4.8, icc 13.0, clang 3.4.1. All the compilers I have tried give an error along the lines of:
error: request for member ‘isValid’ in ‘tableInfo’, which is of non-class type ‘TableInfo(FullObjId&)’