J
Jean-Louis Leroy
I'm trying to compile the following code with gcc (version below). I
would expect the compile to try the operator ==() declared in
Tangram::Backend because of Koenig lookup. But it doesn't happen. Is
it me or the compiler?
namespace Tangram {
namespace Backend {
struct RELATIONAL;
template<typename B>
struct Expression_Handle {
Expression_Handle();
Expression_Handle(int);
};
template<typename B>
struct Predicate_Handle {
};
template<typename B>
Predicate_Handle<B> operator ==(const Expression_Handle<B>&, const Expression_Handle<B>&);
}
namespace Relational {
using Backend::RELATIONAL;
typedef Backend::Expression_Handle<RELATIONAL> Expression;
}
}
void foo() {
using namespace Tangram::Relational;
Expression expr;
expr == Expression(666); // ok
expr == 666; // error: no match for 'operator==' in 'expr == 666'
}
Here's my gcc:
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=i386-redhat-linux
Thread model: posix
gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)
would expect the compile to try the operator ==() declared in
Tangram::Backend because of Koenig lookup. But it doesn't happen. Is
it me or the compiler?
namespace Tangram {
namespace Backend {
struct RELATIONAL;
template<typename B>
struct Expression_Handle {
Expression_Handle();
Expression_Handle(int);
};
template<typename B>
struct Predicate_Handle {
};
template<typename B>
Predicate_Handle<B> operator ==(const Expression_Handle<B>&, const Expression_Handle<B>&);
}
namespace Relational {
using Backend::RELATIONAL;
typedef Backend::Expression_Handle<RELATIONAL> Expression;
}
}
void foo() {
using namespace Tangram::Relational;
Expression expr;
expr == Expression(666); // ok
expr == 666; // error: no match for 'operator==' in 'expr == 666'
}
Here's my gcc:
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=i386-redhat-linux
Thread model: posix
gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)