I have a problem with the following Minimal Example:
enum class modes_t {m1=0u, m2=1u};
class A {
public:
static inline A& get(void) noexcept{
static A inst;
return inst;
}
template<modes_t mode>
inline void start(void) noexcept {}
};
template<typename T>
class B {
public:
static inline void start(void) noexcept {
T::get().start<modes_t::m1>();
}
};
int main() {
B<A>::start();
}
If I compile it with g++ v.7.3, (with -std=c++17 and also with -std=c++14) I get the following errors:
main.cpp: In static member function ‘static void B<T>::start()’:
main.cpp:17:37: error: expected primary-expression before ‘)’ token
T::get().start<modes_t::m1>();
^
main.cpp: In instantiation of ‘static void B<T>::start() [with T = A]’:
main.cpp:22:11: required from here
main.cpp:17:23: error: no match for ‘operator<’ (operand types are ‘<unresolved overloaded function type>’ and ‘modes_t’)
T::get().start<modes_t::m1>();
So the compiler thinks, that the line T::get().start<modes_t::m1>();
is a less then comparison of T::get().start
and modes_t::m1
.
What should I do, to tell the compiler, that this expression should call start()
in class A
?