The following hpp and cpp files are an excerpt from a large program that I am working with. It will compile with g++ -std=c++17 -pedantic -Wall -Wextra
.
// a.hpp
#include <memory>
class A
{
std::unique_ptr<class A_impl> my;
};
//a.cpp
#include "a.hpp"
int main()
{}
But I don't understand about the syntax on the line regarding the unique pointer.
Questions:
What's the syntax for
<class A_impl>
? What's this (puttingclass
before an undeclared identifier) called? Is it doing a "forward declaration" onA_impl
or what? I haven't said anything about the identifierA_impl
. How come the compiler is okay with that?If this happens to be possibly related to any "design pattern", please help me identify it.
Please point out the right direction.