Hello everyone. I had a problem when I try to call a helper function from my a::util namespace.
My code can not be compiled: error: use of ‘this’ in a constant expression (refer to the calling of util::count();)
Do you have idea? Where should I place my helper functions. I think they do not belong to a class. Do they?
//--------a.hh----------
#include "util.hh"
namespace a {
Class DB {
A a;
int foo() {
return util::count();
}
}
}
//--------util.hh----------
namespace a {
namespace util {
template <class E, class C>
int count();
templace<> int count<int, int>() {
return 42;
}
}
}
It looks like it will not be able to deduce the template arguments so you will probably need to specify the types explicitly when calling util::count().
return util::count<int, int>();
Not sure if this is related to your error message or not. It's hard to say what the problem is because your code is incomplete and contains many mistakes.