Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm standing by for the announcement that some caffeine-addled Boost metaprogramming madman has implemented the Rust borrow checker as a C++ template, or at least thinks that he may have, when the compilation completes sometime in the 2030s.



It's not clear how much boost.org magic they used. Failing that, a GCC extension could be needful.

From the ref:

---

Conclusion

We attempted to represent ownership and borrowing through the C++ type system, however the language does not lend itself to this. Thus memory safety in C++ would need to be achieved through runtime checks.

Example code

#include <type_traits>

#include <utility>

#include <assert.h>

#include <stddef.h>


Why use template metaprogramming? You can use compiler extensions for that since the code will be valid either way


C++ has the Maximum Pain Rule.

Templates it must be.


There is a branch of clang with support for "-Wlifetime" which might be a simpler alternative.


It is not like I didn't try...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: