Note that there are some explanatory texts on larger screens.

plurals
  1. POTemplate Run version Different from Debug
    primarykey
    data
    text
    <p>I have an object like the following </p> <pre><code>template&lt;typename T&gt; inline void UnusedParameter( T const&amp; ) { } class Client { public: template&lt;class T&gt; void runFFT(T *wSamples, float const &amp;fMult) { std::cout &lt;&lt; "INSIDE RUNFFT : : :" &lt;&lt; std::endl; UnusedParameter(wSamples); UnusedParameter(fMult); } }; </code></pre> <p>And in my CPP I have the following:</p> <pre><code>#include "object.hpp" template&lt;&gt; void Client::runFFT&lt;int16_t&gt;(int16_t *wSamples, float const &amp;fMult) { std::cout &lt;&lt; "INSIDE INT16_T version: : :" &lt;&lt; std::endl; UnusedParameter(wSamples); UnusedParameter(fMult); } template&lt;&gt; void Client::runFFT&lt;Ipp32f&gt;(Ipp32f *wSamples, float const &amp;fMult) { std::cout &lt;&lt; "INSIDE IPP32F version: : :" &lt;&lt; std::endl; UnusedParameter(wSamples); UnusedParameter(fMult); } </code></pre> <p>Both these implementation run without any problem in my Debug Code. It enters the int16_t version without problem and the Ipp32f version also without problem.</p> <p>But when I try the Run version it only enters the Template, like the compiler only compiles the Template implementation in the header.</p> <p>How do I prevent this from happenning? Shall I remove this and just create two different methods? I love my templates but these Heisenberg bugs are frustating.</p> <p>Thanks for any input. </p> <p>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p> <p>Andy Prowl answered this question and it is solved doing the following in the HPP:</p> <pre><code>template&lt;typename T&gt; inline void UnusedParameter( T const&amp; ) { } class Client { public: template&lt;class T&gt; void runFFT(T *, float const &amp;) { // Thanks for Joachim for removing my Unused Parameter crap std::cout &lt;&lt; "INSIDE RUNFFT : : :" &lt;&lt; std::endl; } }; template&lt;&gt; void Client::runFFT&lt;int16_t&gt;(int16_t *wSamples, float const &amp;fMult); template&lt;&gt; void Client::runFFT&lt;Ipp32f&gt;(Ipp32f *wSamples, float const &amp;fMult); </code></pre> <p>And now it works in runtime as well. The CPP stays the same.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload