3 ms·
> Not sure I like this pointer. Copying a pointer should not be a heavyweight operation. That is pretty well established. An alternative option would be a uniq
by masklinn 9y ago
> Not sure I like this pointer. Copying a pointer should not be a heavyweight operation. That is pretty well established.
An alternative option would be a unique_ptr subtype (or extension) which allows cloning if the wrapped type is clonable, something similar to rust's
impl<T> Clone for Box<T> where T: Clone
Can that be expressed without concepts?
- petters 9y agoYes, but it is a bit awkward. You can can separate implementations depending on whether T has a particular member function. I need to look up how every time, though.
- masklinn 9y ago> You can can separate implementations depending on whether T has a particular member function. Separate implementation, but not separate interface? The Rust bit means Box is "transparently" clonable, meaning it only implements the clone trait(/interface) if the value it wraps also does, trying to clone a Box<T> where T can not be cloned would be a compile-time error.