There is no shortage of design - in fact, this design is just one step away from the well-known and very useful composite template . However, there is a significant drawback in the implementation.
Your CompositeProperty combines Property instances, not aggregates pointers. This kills the ability to use CompositeProperty elements polymorphically. To solve this problem, you need to replace the instance vector with a vector of pointers (preferably smart pointers).
The classic place for a compound template is to represent expression trees: you start with an abstract base, and then add representations for constants, variables, function calls, unary expressions, binary expressions, conditional expressions, etc. Expressions, such as constants and variables, do not refer to other expressions, while expressions, such as unary expressions, binary expressions and function calls. This makes a recursive object graph, allowing you to represent expressions of arbitrary complexity.
source share