From CppCon2018

Among the CppCon2018 slide packs the one I’ve liked most are this one that shows how C++ is progressing in integrating a limited lifetime checker:

And especially this one, shows how several features of modern C++ could be used to perform multi-precision arithmetic for cryptographic applications, with a nice API and very efficiently for numbers about 200 bits long:

It uses user-defined literals to express the modulus (but it seems to store them as an array of uint64_t instead of an array of size_t), overloads operators, performs computations and optimizations as much as possible at compile-time (using several modern C++ compile-time features, plus Barrett / Montgomery reduction precomputed at at compile time), it uses std::integer_sequence (but slide 26 shows how it cuts off tailing zeros, it seems very bad code. The same compile-time code in D language should come out much nicer), and then performs some static analysis with Cryptol, SAW and ct-verif.

2 Likes

Interesting, judging from last couple of slides in the first link, it seems that C++ does not rely on the function body to infer lifetime defaults after all; it is all in the signature, like Rust.

Hard for me to tell what their lifetimes mean exactly without seeing the talk, though. My perception is colored by Rust, and all I can say is that these lifetimes work very differently.