[vtk-developers] vtkNew compile error

Brad King brad.king at kitware.com
Mon Mar 22 16:46:43 EDT 2010


Brad King wrote:
> STYLE: Remove member-template check
> /cvsroot/VTK/VTK/Common/vtkSmartPointer.h,v  <--  Common/vtkSmartPointer.h
> new revision: 1.17; previous revision: 1.16
> 
> ENH: Add vtkNew<> to create objects locally
> /cvsroot/VTK/VTK/Common/CMakeLists.txt,v  <--  Common/CMakeLists.txt
> new revision: 1.236; previous revision: 1.235
> /cvsroot/VTK/VTK/Common/vtkNew.h,v  <--  Common/vtkNew.h
> initial revision: 1.1
> /cvsroot/VTK/VTK/Common/vtkSmartPointer.h,v  <--  Common/vtkSmartPointer.h
> new revision: 1.18; previous revision: 1.17
> /cvsroot/VTK/VTK/Common/Testing/Cxx/TestSmartPointer.cxx,v  <--  Common/Testing/Cxx/TestSmartPointer.cxx
> new revision: 1.12; previous revision: 1.11

Ugh, this does not work on all compilers, even on some conforming ones.

The syntax

  vtkSmartPointer<vtkBaseClass> b = vtkNew<vtkDerivedClass>();

does not work as implemented.  C++98 12.2/2 allows the compiler to
copy-construct an extra vtkNew<> temporary to which to bind the
reference of b's constructor.  Since vtkNew<> does not provide copy
semantics (and cannot by design) this fails on compilers that choose to
copy the temporary unnecessarily.

I'm reverting this feature until we have time to investigate further.

Sorry,
-Brad


COMP: Revert "Add vtkNew<> to create objects locally"
/cvsroot/VTK/VTK/Common/CMakeLists.txt,v  <--  Common/CMakeLists.txt
new revision: 1.237; previous revision: 1.236
/cvsroot/VTK/VTK/Common/vtkNew.h,v  <--  Common/vtkNew.h
new revision: delete; previous revision: 1.1
/cvsroot/VTK/VTK/Common/vtkSmartPointer.h,v  <--  Common/vtkSmartPointer.h
new revision: 1.19; previous revision: 1.18
/cvsroot/VTK/VTK/Common/Testing/Cxx/TestSmartPointer.cxx,v  <--  Common/Testing/Cxx/TestSmartPointer.cxx
new revision: 1.13; previous revision: 1.12



More information about the vtk-developers mailing list