edit: the linked one doesn't solve this particular case, since in my case there is a nested type.
Lets imagine the situation is like this:
//foo.hpp
//include guards
template <typename T>
class foo
{
class bar;
};
The code for bar
is too big, so I'd like (not really me, but it doesn't matter) to another file.
So, the current situation is this:
//foo.hpp
#include <bar.hpp>
//include guards
template <typename T>
class foo
{
class bar;
};
//bar.hpp
#include <foo.hpp>
//include guards
template <typename T>
class foo::bar
{
//...
}
This is certainly circular dependency. But the thing is that compiler (clang and gcc) accepts it.
Should I fix it or there is nothing to fix? If it is an error, how should I fix it? Should I just dump everything into one file and call it a day?
In reality, that bar
is an iterator, which I wouldn't want to make standalone.
There are include guards there, so I guess that is what prevents it from being included many times, but still the circular dependency makes me worried.