Show HN: Beautiful Type Erasure with C++26 Reflection (ryanjk5.github.io)
Try it on Compiler Explorer: https://godbolt.org/z/91dj5jeGW
Check out the source code: https://github.com/RyanJK5/rjk-duck
Check out the source code: https://github.com/RyanJK5/rjk-duck
25 comments
[ 4.3 ms ] story [ 57.5 ms ] thread...but, as they say, beauty is in the eye of the beholder!
People ended up getting celebrated for their cleverness and not horrified by the abuse of good taste, and many of these tricks appeared in core C++ libraries like Boost.
So doing stuff like this is unfortunately just part of C++ culture, and allows you to emulate proper features that using a C++ standard that's at least a decade older.
I see there's an issue in the tracker to get more accurate data, and since it's using an under dev feature in compilers, it's not going to be definitive, but any rough numbers?
```
10: rjk::duck<Container> c{std::vector<int>{1, 2, 3}};
11: c.size(); // 3
12:
13: c = std::string{"hello"};
```
Does the assignment on line 13 call the destrucor for the vector of ints created on line 10?
Or you just used void* and went on with your life