Changes between Initial Version and Version 1 of Ticket #681
- Timestamp:
- 01/06/15 11:36:03 (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #681 – Description
initial v1 20 20 You can only correctly copy an object of a known subclass - if you try to copy an object via a pointer or reference to the base class, either it will only copy the base class (slicing the object), or if the base class is abstract it will fail to compile. 21 21 22 User code which is making use of this is presumably doing something like passing by value instead of by reference, or keeping a vector of these objects which copies them when the internal storage is reallocated (a vector of pointers would be a better approach - even if copying the subclass is cheap, `vector<FooKeyMaker>` can only hold objects which are exactly of class `FooKeyMaker`, whereas `vector<KeyMaker*>` or vector<unique_ptr<KeyMaker>>` can hold an object of any subclass of `KeyMaker`).22 User code which is making use of this is presumably doing something like passing by value instead of by reference, or keeping a vector of these objects which copies them when the internal storage is reallocated (a vector of pointers would be a better approach - even if copying the subclass is cheap, `vector<FooKeyMaker>` can only hold objects which are exactly of class `FooKeyMaker`, whereas `vector<KeyMaker*>` or `vector<unique_ptr<KeyMaker>>` can hold an object of any subclass of `KeyMaker`). 23 23 24 24 Unless there's a situation in which this copying or assignment is an appropriate way to achieve something, I propose we simply disable this in 1.3.x, rather than having the usual deprecation cycle - it's not quite "a feature which [doesn't] actually work", but to me it looks like one which is sufficiently problematic that you wouldn't knowingly use it.