Skip to main content

Is it possible to achieve Rust's ownership model with a generic C++ wrapper?

Tweeted twitter.com/StackProgrammer/status/730205894647152641
Source Link
Brannon
  • 371
  • 1
  • 9

possible to achieve Rust's ownership model with a generic C++ wrapper?

Looking through this article on Rust's concurrency safety:

http://blog.rust-lang.org/2015/04/10/Fearless-Concurrency.html

I was wondering how many of these ideas can be achieved in C++11 (or newer). In particular can I create an owner class that transfers ownership to any method to which it may be passed? It seems that C++ has so many ways to pass variables that it would be impossible, but maybe I could put some restrictions on the class or template to ensure that some template code gets executed with every method pass?