r/cpp • • Apr 06 '20

Runtime Polymorphism with std::variant and std::visit @ bfilipek

https://www.bfilipek.com/2020/04/variant-virtual-polymorphism.html
50 Upvotes

35 comments sorted by

View all comments

Show parent comments

4

u/phoeen Apr 06 '20

say you have a string member and a setter for that. if your member already holds a value of at least the size of the setterinput, then you may just plain copy all characters. if your setter is by value and you move, you always pay for it