Reputation: 14081
As of January 2018, what is the most modern style for forward declarations? We use something like below, but is there a more compact version?
Could I write something like class Foo::Bar
(does not work for me, but maybe I miss a newer C++ standard)? Or any more compact version?
Current style:
namespace Foo
{
class SimpleCommandParser;
namespace Bar
{
class Parts;
class Situation;
class Callsign;
}
namespace Yep
{
class AircraftSnapshot;
class Aircraft;
}
}
There are some questions about similar topics like Forward Declaration in a nested namespace , but they are quite old.
Upvotes: 1
Views: 329
Reputation: 238321
As of January 2018, forward declaration of a name into a namespace is still the same as it was since first version of the standard i.e. the declaration must be within that namespace.
Could I write something like
class Foo::Bar
Not in a current (C++17) standard.
There has been a proposal P0289R0 to add just such feature, but it hasn't been followed through and such change hasn't been introduced to the standard as of C++17.
Upvotes: 3