Re:Show HN: Crown – A flexible game engine written from scra...
by maccard on Friday June 23, 2017 @09:22AM
(#14618942)
That still means you can't creat instances of Foo on the stack though, doesn't it? Or you can't have a storage or contiguous Foo's (e.g. vector<Foo>)
[ Parent
| on HN ]
Re:Show HN: Crown – A flexible game engine written from scra...
by imron on Friday June 23, 2017 @11:10AM
(#14619707)
Correct. It means you can't create instances of Foo on the stack (outside of the Foo class).
You can have contiguous Foos, but not in a vector. You can either have another static function to return an array of Foos, or more commonly have some sort of pool allocator and have the create function allocate objects from the pool.
Anyway, yes, there are limitations for using this pattern, so like all things it's a matter of weighing up the tradeoffs.