Let's assume I have such situation:
//A.hpp
#include "B.hpp"
#include "C.hpp"
#include "D.hpp"
using A = boost::variant<B, C, D>;
//B.hpp
#include <memory>
class A;
using AA = std::unique_ptr<A>;
This give me following error: error: typedef redefinition with different types ('boost::variant<B, C, D>' vs 'A')
I can't omit #include's in A.hpp because boost::variant wants complete types.
How to forward declare A which is defined with using?
If it is not possible, I would like to now, how to solve my problem avoiding a lot of boilerplate code.
That's not relevant since you're not instantiating a
boost::varianthere.Go ahead and omit the
#includes.(live demo)
Then your problem evaporates:
Don't. Use
usingagain or, better yet, hoist theusingstatement into its own header that may then be included wherever it's needed.