[Insight-users] no itkSetOutputMacro?
Luis Ibanez
luis.ibanez at kitware.com
Sat Jan 18 11:28:38 EST 2014
On Mon, Jan 13, 2014 at 4:25 AM, Joël Schaerer <joel.schaerer at gmail.com>wrote:
>
>> Given that in C++, the return type is not part of the signature of a
>> function,
>> we couldn't have two methods with the same name and input parameters
>> but with different return types.
>>
>> Namely:
>>
>> DataObject * myFilter->GetTransform();
>> TransformType * myFilter->GetTransform();
>>
>>
> Couldn't the output macro get a type parameter, similarly to the input
> macro?
>
> itkGetOutputMacro(name,type)
>
> That would generate the second method directly, with no conflict if I
> understand correctly. Unless of course you want the output type to be
> dynamic, which doesn't seem like a very frequent case.
>
> What am I missing?
>
>
Joel,
The macro that you suggest could indeed generate the two functions above.
But C++ will not allow us to have two functions whose only difference is
the return type.
The following example may help to illustrate the problem:
cat returntype.cxx
class Foo {
int bar();
float bar();
};
g++ -c returntype.cxx
returntype.cxx:4:7: error: ‘float Foo::bar()’ cannot be overloaded
returntype.cxx:3:7: error: with ‘int Foo::bar()’
Regards,
Luis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20140118/988cd24c/attachment.html>
More information about the Insight-users
mailing list