So I've read through this: https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
And understand how Curiously Recurring Template Pattern (CRTP) works. But it seems like it depends upon the compiler implementation, specifically that the compiler:
- Defines the space required for each Template Class
- Then compiles the child class's methods
- Then compiles the parent class's methods
While I can see how this order allows compilation I feel like it's an leveraging compiler construction rather than an order of compiler passes required by the standard. But I feel like an equally legitimate set of compiler passes would be to:
- Define the space required for the parent class
- Compile the parent classes methods
- Define the space required for the child class
- Compile the child classes methods
If the compiler used these passes CRTP would fail on step 2 when it attempts to evaluate a child type.
So I've just made up these compiler passes, but is there a standard requirement that places constraints on the compiler that it much adhere to the 3 passes of the 1st? Or does CRTP exist in a grey area of knowing how compilers are implemented currently?
As I see it to allow that the standard would need to require a 1st pass that establishes object sizes, followed by a 2nd pass that compiles methods. But this 2nd pass wold have to be willing to build a child objects methods before the parent objects, which seems backwards.