<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello David,<div><br></div><div>You can simply overload the function with both the pointer and the SmartPointer arguments as was done with the constructor here:</div><div><br></div><div><a href="http://www.itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1Image.html">http://www.itk.org/SimpleITKDoxygen/html/classitk_1_1simple_1_1Image.html</a></div><div><br></div><div>Brad</div><div><br><div apple-content-edited="true">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">========================================================</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Bradley Lowekamp<span class="Apple-converted-space">&nbsp;</span><span class="Apple-converted-space">&nbsp;</span></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Medical Science and Computing for</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">Office of High Performance Computing and Communications</font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; ">National Library of Medicine<span class="Apple-converted-space">&nbsp;</span></font></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><font face="Helvetica" size="3" style="font: normal normal normal 12px/normal Helvetica; "><a href="mailto:blowekamp@mail.nih.gov">blowekamp@mail.nih.gov</a></font></p></div></div></span></span>
</div>
<br><div><div>On Jan 7, 2012, at 4:59 PM, David Doria wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>I have a tons functions with this type of signature:<br><br>template &lt;typename TImage&gt;void MyFunction(TImage* image)<br>If I create an image like this:<br><br>typedef itk::Image&lt;int, 2&gt; ImageType;<br>ImageType::Pointer image = ImageType::New();<br><br>And pass it like this:MyFunction(image);<br><br>I get an 'undefined function' error.<br><br>It works if I explicitly specify the template<br>parameter:MyFunction&lt;ImageType&gt;(image);<br><br>It also works if I pass the raw pointer:MyFunction(image.GetPointer());<br>If I change the function parameter to:<br><br>template &lt;typename TImage&gt;<br>void MyFunctionSmartPointer(typename TImage::Pointer image)<br><br>again it works if I explicitly specify the template parameter:<br>MyFunctionSmartPointer&lt;ImageType&gt;(image);<br><br>but still doesn't work if I just pass the smart pointer:<br>MyFunctionSmartPointer(image);<br><br>and curiously also doesn't work with the raw pointer:<br>MyFunctionSmartPointer(image.GetPointer());<br><br>Is there anything that can be done to pass a smart pointer to a<br>function and have it automatically deduce the type?<br><br>Thanks,<br><br>David<br>_____________________________________<br>Powered by <a href="http://www.kitware.com">www.kitware.com</a><br><br>Visit other Kitware open-source projects at<br><a href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br><br>Kitware offers ITK Training Courses, for more information visit:<br>http://www.kitware.com/products/protraining.html<br><br>Please keep messages on-topic and check the ITK FAQ at:<br>http://www.itk.org/Wiki/ITK_FAQ<br><br>Follow this link to subscribe/unsubscribe:<br>http://www.itk.org/mailman/listinfo/insight-users<br></div></blockquote></div><br></div></body></html>