I am trying to do the following code work
template < class __derived, class __object = typename __derived::Object >
struct Base {
using Derived = __derived;
using Object = __object;
void function(Object o) { return Derived::function(s); }
}
template < class __object >
struct Derived : public Base< Derived< __Object > > {
using Object = __object;
void function(Object o) { ... }
}
And I create an object by declaring
Derived<double> obj;
The problem is that the compiler claims that it cannot find the character Objectinside the class Derivedby displaying the second template parameter for the class Base. The same error is also generated by comments.
I am trying to do this under the inspiration of Eigen3 code, especially CRTP (Curiously Recurring Template Pattern), which they use to avoid using virtual functions. Eigen3 actually uses the class traits, but I cannot figure out how to mimic this for this case. Anyone have any suggestions on this? Thanks in advance!