I'm working with a codebase where I can't solve this circular dependency:
foo.h
class Foo
{
public:
using Ptr = std::shared_ptr<Foo>;
using ConstPtr = std::shared_ptr<const Foo>;
void setter(const Bar::Ptr& bar_ptr) {};
private:
Bar::WeakPtr bar_ptr_;
};
and
bar.h
class Bar
{
public:
using Ptr = std::shared_ptr<Bar>;
using ConstPtr = std::shared_ptr<const Bar>;
using WeakPtr = std::weak_ptr<Bar>;
Bar(Foo::ConstPtr foo_ptr) : foo_ptr_(std::move(foo_ptr)) {};
private:
Foo::ConstPtr foo_ptr_;
};
It was previously compiling because there was an external header where:
using FooPtr = std::shared_ptr<Foo>;
using FooConstPtr = std::shared_ptr<const Foo>;
using BarPtr = std::shared_ptr<Bar>;
But since consistency is sought after, I'd like to have Foo::Ptr, Foo::ConstPtr, Bar::Ptr. Any chance I can get it?
EDIT: added the Bar::WeakPtr which was previously missing since I thought I was already in trouble.