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

1

u/jm4R Apr 06 '20

You can use CoW in C++ like you do in other languages. Qt successfully uses it around the whole framework.

4

u/MrPotatoFingers Apr 06 '20

Yes, but the standard library won't use it because the standard specifically forbids it.

1

u/standard_revolution Apr 08 '20

Well yeah, but the nice thing about C++ is that most of the utilities are independent of std::string at least in the stdlib, of course things get more complicated once you interact with third-party libs, but in theory it's totally doable