• Allison Vacanti's avatar
    Update smart pointer semantics for C++11. · 30605cd7
    Allison Vacanti authored
    This adds complete move and noexcept semantics to vtkNew, vtkWeakPointer,
    and vtkSharedPointer, while doing more robust type-checking. In
    particular, this patch may expose bugs of the form:
    
    vtkWeakPointer<vtkRenderer> ren = ...;
    vtkWeakPointer<vtkCamera> cam = ...;
    cam = ren; // Shouldn't compile: types are unrelated.
    
    since vtkWeakPointer can no longer be constructed from an arbitrary
    vtkWeakPointerBase.
    
    Similarly, the comparisons between these objects has been updated.
    Comparing unrelated pointers is illegal in C++, and code such as:
    
    vtkSmartPointer<vtkIntArray> array1 = ...;
    vtkSmartPointer<vtkFloatArray> array2 = ...;
    if (array1 == array2) { ... }
    
    no longer compiles (similar to comparing float* and int*).
    
    All move operations are made noexcept to allow optimizations when stored
    in std containers (e.g. std::vector reallocs will now move instead of
    copy, bypassing reference counting).
    
    Note that some move operations (eg. move-constructing vtkWeakPointer from
    vtkNew, or move-assigning to a vtkSmartPointer) are not implemented, as
    they either don't makes sense, or don't provide any advantage over copying.
    
    vtkWeakPointer has been updated to treat vtkNew<T> like T* when
    constructing or assigning, similar to vtkSmartPointer.
    
    The enable_if statements have been replaced with static_asserts, since
    these will give nicer error messages ("Pointee types are incompatible",
    rather than "no matching overload found").
    30605cd7