[odb-users] template ambiguity with gcc4.8
Paul Harrison
Paul.Harrison at manchester.ac.uk
Sun Sep 29 12:53:15 EDT 2013
Hi,
we have some code that compiles fine with gcc4.2 and gcc4.4, but with gcc4.8 we get
In file included from /home/rgn/develop/emer/branches/newpersist/emerlin/include/configs_db/tel_configs_db.h:20:0,
from /home/rgn/develop/emer/branches/newpersist/emerlin/include/emerlin_msgs/band_table.h:15,
from /home/rgn/develop/emer/branches/newpersist/emerlin/emerlin_msgs/source/band_table.C:9:
/home/rgn/develop/emer/branches/newpersist/emerlin/include/persist2/odb_lib_impl.h: In instantiation of ‘void ODB_Library::update_collection(boost::shared_ptr<X>&, std::list<boost::shared_ptr<U> >&, std::list<boost::shared_ptr<U> >&) [with P = Band_Table_Entry_P; C = Local_Oscillator_P]’:
/home/rgn/develop/emer/branches/newpersist/emerlin/emerlin_msgs/source/band_table.C:576:59: required from here
/home/rgn/develop/emer/branches/newpersist/emerlin/include/persist2/odb_lib_impl.h:203:9: error: call of overloaded ‘erase(const boost::shared_ptr<Local_Oscillator_P>&)’ is ambiguous
_database->erase<C>(*i);
^
/home/rgn/develop/emer/branches/newpersist/emerlin/include/persist2/odb_lib_impl.h:203:9: note: candidates are:
In file included from /usr/local/include/odb/mysql/database.hxx:440:0,
from /home/rgn/develop/emer/branches/newpersist/emerlin/include/persist2/odb_lib.h:24,
from /home/rgn/develop/emer/branches/newpersist/emerlin/include/persist2/odb_lib_impl.h:11,
from /home/rgn/develop/emer/branches/newpersist/emerlin/include/configs_db/tel_configs_db.h:20,
from /home/rgn/develop/emer/branches/newpersist/emerlin/include/emerlin_msgs/band_table.h:15,
from /home/rgn/develop/emer/branches/newpersist/emerlin/emerlin_msgs/source/band_table.C:9:
/usr/local/include/odb/mysql/database.ixx:280:17: note: void odb::mysql::database::erase(const P<T>&) [with T = Local_Oscillator_P; P = boost::shared_ptr]
inline void database::
^
/usr/local/include/odb/mysql/database.ixx:326:17: note: void odb::mysql::database::erase(const typename odb::object_traits<T>::pointer_type&) [with T = Local_Oscillator_P; typename odb::object_traits<T>::pointer_type = boost::shared_ptr<Local_Oscillator_P>]
inline void database::
^
The code that is doing the calling is
//remove values
for(typename std::set<shared_ptr<C> >::iterator i = rem.begin(); i != rem.end(); ++i){
_database->erase<C>(*i);
}
itself a template, but with the shared pointer declared with
using boost::shared_ptr;
At first sight gcc4.8 is correct - these erase functions in odb/mysql/database.hxx do end up being ambiguous with the given template parameters - which makes me wonder how this gets past earlier gcc versions - is there a trick to resolve the ambiguity when calling, because I have to admit that I cannot think of one. (Apart from a workaround of calling erase with the an object reference, or object Id - this is the only place in our code where erase is called with smart pointer to the object).
Regards,
Paul Harrison
More information about the odb-users
mailing list