[odb-users] lookup ambiguity on db.query member template

Boris Kolpackov boris at codesynthesis.com
Mon Apr 30 10:46:24 EDT 2012


Hi Daniel,

Daniel James <danielpeterjames at gmail.com> writes:

> I'm getting the following warning when compiling with clang:
> 
> driver.cxx:71:31: warning: lookup of 'query' in member access expression is
>      ambiguous; using member of 'odb::sqlite::database'
>      [-Wambiguous-member-template]
>        odb::result<Array> arrays(db.query<Array>());

Yes, I saw these when testing the upcoming release of ODB with Clang.
It looks like Clang is following some obscure (and possibly misguided)
C++ rule to the letter (as it tends to do). I can't see how query in
the db.query<Array>() expression can possibly be ambiguous. The part
that is triggering the ambiguity is this using directive:

using namespace odb::core;

It brings odb::query class template to the global namespace where Clang
manages to find it.

I couldn't come up with a non-invasive fix for this warning on my side.
It looks like the only way to get rid of it for good is to rename 
database::query() or odb::query (or remove odb::query from odb::core).
I like none of these options.

On the user side the fix is easy, however; simply don't use the using
namespace odb::core directive (I see you are qualifying odb::result
anyway).

Boris



More information about the odb-users mailing list