I am a developing a C++ header only library.

There are several parts of the code which follow this pattern:

**holder.h**

```
#pragma once

#include "sub.h"

struct Holder
{
    void f();
    Sub s;
};

```

**sub.h**

```
#pragma once

struct Holder;

struct Sub
{
   void g(Holder& h);
};

#include "sub.ipp"

```

**sub.ipp**

```
#include "holder.h"

inline void Sub::g(Holder& h)
{
    h.f();
}

```

*sub.h* avoids the circular dependency on *Holder* using forward declaration. However, in *holder.h* as the *Holder* class contains a *Sub* member it needs to see the full declaration of *Sub* in *sub.h*. *sub.h*, however, pulls in the implementation in *sub.ipp* which can't be instantiated yet as it needs the definition of *Holder* and we are already inside *holder.h* so we can't include it again.

As I user of any of these headers I would like to only have to include the correct *.h* file and not have to worry about manually including the correct *.ipp* files in strange places.

What is the standard solution to this?