Hacker News new | ask | show | jobs
by adjav 971 days ago
Clang 18 supports `import std;` now, but you need to enable some build settings [1]. Also has `deducing this` support, which is nice - I am fully in favour of C++ continuing to poach the good parts of Rust.

[1] https://libcxx.llvm.org/Modules.html

2 comments

Deducing this is not a feature analogous to anything in Rust, the language with almost no type deduction at all. It bears a vague similarity to constrained generic traits, but you really have to squint to see it.
Of course you're correct that Rust has no support for making the `Self` type itself generic, which is the core of the "deducing this" feature.

However, "deducing this" has the side-effect of allowing to explicitly specify the "this" parameter in the argument list. The syntax looks the same as Rust, and the convention of calling this parameter "self" is taken from "other languages" (Python, Rust, ...)[0].

Similarly, it could be argued that the ability to pass the object by value in method is lifted from Rust. That's how I understand the GP comment anyway.

[0]: https://devblogs.microsoft.com/cppblog/cpp23-deducing-this/ "You don’t have to use the names Self and self, but I think they’re the clearest options, and this follows what several other programming languages do."

The good part of rust isn't anything they added, it's everything that's gone