I have in my header a typedef
which is a member of class cl1
template <size_t d>
class my_wkspc::cl1 {
public:
typedef std::vector<real> table_t;
...
typename my_wkspc::cl2<d>& getCl2() { return _cl2; } // <------ Not yet used
...
private:
typename my_wkspc::cl2<d>& _cl2; // <------ Not yet used
};
and I need that typedef
for a class member and functions in class cl2
namespace my_wkspc {
template <size_t d>
class cl2 {
public:
typename cl1<d>::table_t& getTable() const { return _table; }
...
private:
typename cl1<d>::table_t& _table;
...
};
Now I also need to define cl1
class members of type cl2
(not yet implemented).
I think that I could forward declare cl2
, and place any cl1
member function requiring knowledge of cl2
in a source file (PS: this would break my header-only classes).
But can I place cl2
class definition above cl1
, with some kind of forward-declaration of typedef std::vector<real> table_t
?
In Forward declare typedef within C++ class it is asked something similar (even more difficult, with reciprocal uses of typedef
s), but the OP is very old, and answers (stating this is not doable) might exclude later alternatives.
A late template instantiation is suggested.
Related: