| For those who wants to know c++17 features http://stackoverflow.com/questions/38060436/what-are-the-new... std::optional and std::any are one of the good things. std::apply and std::invoke can help you write better functional c++17 code. Anyway thanks for C++17. For sometime, I thought I will learn Rust. |
On x86_64 Linux, it looks like a function with signature `void f(std::variant<int, char>)` expects its (8-byte) argument to be passed by reference, whereas `void f2(tagged_union_of_int_and_char)` passes its argument in rdi.
gcc (-O3) also generates miserable code for calling f(42):
as compared with calling f2(42): std::optional seems to have the same disease; the ABI is different from a plain struct containing a bool and the value and you get worse initialisation code. There's also a build time penalty to using std::optional; on my machine, including the code that uses optionals makes my trivial test program take 320ms to compile and link rather than 50ms.These look like yet more new C++ features that are worse than what they're trying to replace.