"hides overloaded virtual function [-Woverloaded-virtual]" warnings with llvm/clang
Created by: laurentes
I've noticed the following warnings when we use the llvm/clang compiler (only on OS X):
/Users/buildbot/work/buildbot/macosx-10.8-x86_64-incremental+master/build/include/bob/trainer/IVectorTrainer.h:122:10: warning: 'bob::trainer::IVectorTrainer::is_similar_to' hides overloaded virtual function [-Woverloaded-virtual]
1 warning generated.
/Users/buildbot/work/buildbot/macosx-10.8-x86_64-incremental+master/build/include/bob/trainer/IVectorTrainer.h:122:10: warning: 'bob::trainer::IVectorTrainer::is_similar_to' hides overloaded virtual function [-Woverloaded-virtual]
1 warning generated.
cf. here
I don't understand why this is occuring. Does anyone have a clue? The recipe to get rid of them is to change the inline definition in the templated class EMTrainer
virtual bool is_similar_to(const EMTrainer& b, const double r_epsilon=1e-5, const double a_epsilon=1e-8) const
{
return m_compute_likelihood == b.m_compute_likelihood &&
bob::core::isClose(m_convergence_threshold, b.m_convergence_threshold, r_epsilon, a_epsilon) &&
m_max_iterations == b.m_max_iterations;
}
into a single declaration within the EMTrainer class definition
bool is_similar_to(const IVectorTrainer& b, const double r_epsilon=1e-5, const double a_epsilon=1e-8) const;
and a definition of this method outside the class as follows
template<class T_machine, class T_sampler>
bool bob::trainer::EMTrainer<T_machine,T_sampler>::is_similar_to(const bob::trainer::EMTrainer<T_machine,T_sampler>& b,
const double r_epsilon, const double a_epsilon) const
{
return m_compute_likelihood == b.m_compute_likelihood &&
bob::core::isClose(m_convergence_threshold, b.m_convergence_threshold, r_epsilon, a_epsilon) &&
m_max_iterations == b.m_max_iterations;
}
This only happens for is_similar_to method and not for operator==(), which means that the default/optional arguments might be the cause of the problem.