Changes between Initial Version and Version 1 of Ticket #681


Ignore:
Timestamp:
01/06/15 11:36:03 (10 years ago)
Author:
Olly Betts
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #681 – Description

    initial v1  
    2020You 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.
    2121
    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`).
     22User 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`).
    2323
    2424Unless 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.