A mechanism for treating individual and aggregate objects uniformly

Motivation

  • Objects use other objects’ fields/properties/members through inheritance and composition
  • Composition lets us make compound objects
  • Composite design pattern is used to treat both single (scalar) and composite objects uniformly

Implementation

  • May make use of CRTP
  • Use duck typing in C++
  • A single object can masquerade as collection
    • Foo* begin() { return this; }
    • Foo* end() { return this + 1; }