Date: Sun, 12 Jul 2026 00:05:31 +0100
Compile-time enforcement of ownership is also possible in C++ using compile_assert().
Added an example that demonstrates ownership exclusivity below, enforced at compile-time. Violation of the ownership causes the build to fail (ie not enforced at runtime!). Rust provides similar compile-time guarantees, enforced by the borrow checker.
Any feedback appreciated.
Which other Rust compile-time features are desired for C++?
I can probably make a data-race guarantee at compile-time too.
https://github.com/jonnygrant/compile_assert/blob/main/experiments/ownership.cpp
https://github.com/jonnygrant/compile_assert/blob/main/experiments/float_container.hpp
A two file example
https://github.com/jonnygrant/compile_assert/blob/main/experiments/ownership2.cpp
Regards
Jonathan
Added an example that demonstrates ownership exclusivity below, enforced at compile-time. Violation of the ownership causes the build to fail (ie not enforced at runtime!). Rust provides similar compile-time guarantees, enforced by the borrow checker.
Any feedback appreciated.
Which other Rust compile-time features are desired for C++?
I can probably make a data-race guarantee at compile-time too.
https://github.com/jonnygrant/compile_assert/blob/main/experiments/ownership.cpp
https://github.com/jonnygrant/compile_assert/blob/main/experiments/float_container.hpp
A two file example
https://github.com/jonnygrant/compile_assert/blob/main/experiments/ownership2.cpp
Regards
Jonathan
Received on 2026-07-11 23:05:34
