[vtk-developers] const in set vector macros

Burlen Loring burlen.loring at kitware.com
Fri Nov 7 12:27:18 EST 2008


Hi,

would anyone object to changing the vtkSetVectorXMacro's to respect 
const pointers?
for eg. the change to SetVector3Macro would be:

-virtual void Set##name (type _arg[3]) \
+virtual void Set##name (const type _arg[3]) \
   { \
   this->Set##name (_arg[0], _arg[1], _arg[2]);\
   }


This would be helpful in a situation like:

class A
{
 public:
    const double *GetBlah(){ return this->Blah; }
private:
    double Blah[3];
};

class B : public vtkObject
{
public:
    vtkSetVector3Macro(Bleh,double);
private:
    double Bleh[3];
};

A a;
B *b=B::New();
b->SetBleh(a.GetBlah());

where I want to return a pointer to an array for efficiency but want to 
document, and enforce, that the array's contents aren't to be modified, 
and don't want to end up using const_cast's everywhere I need to pass 
the array to a vtkObject.

-- 
Burlen Loring
Kitware, Inc.
R&D Engineer
28 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-371-3971 x137

-------------- next part --------------
A non-text attachment was scrubbed...
Name: vtkSetGet.h.patch
Type: text/x-diff
Size: 1467 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20081107/861da0d4/attachment-0001.patch>


More information about the vtk-developers mailing list