3 ms·
Putting loops inside virtual functions can't work in any cases. Like when a heterogenous collection is iterated and a virtual call is performed for each object.
by Panzerschrek 5mo ago
Putting loops inside virtual functions can't work in any cases. Like when a heterogenous collection is iterated and a virtual call is performed for each object.
In such cases I prefer using std::variant instead of inheritance, but this works only if all possible types are known ahead of time.
- nly 5mo agoHeterogenous containers are a performance killer for all kinds of other reasons. A vector of variants still wouldn't be optimal. Better to use something like https://www.boost.org/doc/libs/latest/doc/html/poly_collection.html https://www.boost.org/doc/libs/latest/doc/html/poly_collecti...
- 1718627440 5mo agoYeah, no human would work like that. You wouldn't write a sentence for a letter, then go shopping for a single item, then write another sentence, go shopping again, then flush the toilet ...
- gpderetta 5mo ago> A vector of variants still wouldn't be optimal Transpose.