jeudi 4 novembre 2021

Is there a way to forward declare an enum class which is inside a structure that is also forward declared?

I've searched about this but couldn't come up with any idea nor find anything.

I have a forward declared struct Edge and a namespace, where i use an enum class as a parameter from the struct Edge in a function :

struct Edge;
namespace validation { bool is_color_valid(const Edge::Color& color){;} }

struct Edge { enum class Color { Gray, Green, Blue, Yellow, Red }; }

I'm getting "Incomplete type 'Edge' named in nested name specifier" error in function declaration, exactly where const Edge::Color& color is.

So I guess i need to forward declare this enum class which is nested inside a struct so that the compiler should understand that actually the structure is not incomplete. I don't want to relocate the namespace. Is this possible?

Any help appreciated, thanks in advance! :)

Aucun commentaire:

Enregistrer un commentaire