title: How to add void/null as default argument to a function/lambda pointer, in C++?
body: <p><strong>Present signature</strong> is</p>
  <pre><code>template&lt;class TypeData,typename TypeFunc&gt;
  bool isPrime(const TypeData&amp; n,TypeFunc fSqrt,bool debug = false)
  </code></pre>
  <p>and this works perfectly with</p>
  <pre><code>std::cout&lt;&lt;(isPrime(n,fSqrt)?&quot;Positive&quot;:&quot;Negative&quot;)&lt;&lt;'\n';
  </code></pre>
  <p>But, my <strong>intension</strong> is something like</p>
  <pre><code>template&lt;class TypeData,typename TypeFunc&gt;
  bool isPrime(const TypeData&amp; n,TypeFunc fSqrt = nullptr,bool debug = false)
  </code></pre>
  <p>or</p>
  <pre><code>template&lt;class TypeData,typename TypeFunc&gt;
  bool isPrime(const TypeData&amp; n,TypeFunc fSqrt = NULL,bool debug = false)
  </code></pre>
  <p>to be called by</p>
  <pre><code>std::cout&lt;&lt;(isPrime(n)?&quot;Positive&quot;:&quot;Negative&quot;)&lt;&lt;'\n';
  </code></pre>
  <p><em>Overloading</em> is not possible due to a <em>static variable</em> inside the function.<br />
  Only different <code>class TypeData</code> should give different <em>template-functions</em> for this <em>function-template</em>.</p>
  <p>Please help me out with the proper syntax. If C++ does not support this, what is an alternative approach I can use?</p>
  <p><strong>Compile Errors</strong></p>
  <p>for <code>TypeFunc fSqrt = nullptr</code></p>
  <pre><code>main.cpp:90:23: error: no matching function for call to ‘isPrime(int&amp;)’
    std::cout&lt;&lt;(isPrime(n)?&quot;Positive&quot;:&quot;Negative&quot;)&lt;&lt;'\n';
                         ^
  main.cpp:9:49: note: candidate: template bool isPrime(const TypeDate&amp;, TypeFunc, bool)
   template&lt;class TypeDate,typename TypeFunc&gt; bool isPrime(const TypeDate&amp; n,TypeFunc fSqrt = nullptr,bool debug = false) {
                                                   ^~~~~~~
  main.cpp:9:49: note:   template argument deduction/substitution failed:
  main.cpp:90:23: note:   couldn't deduce template parameter ‘TypeFunc’
    std::cout&lt;&lt;(isPrime(n)?&quot;Positive&quot;:&quot;Negative&quot;)&lt;&lt;'\n';
                         ^
  </code></pre>
  <p>for <code>TypeFunc fSqrt = NULL</code></p>
  <pre><code>main.cpp:90:23: error: no matching function for call to ‘isPrime(int&amp;)’
    std::cout&lt;&lt;(isPrime(n)?&quot;Positive&quot;:&quot;Negative&quot;)&lt;&lt;'\n';
                         ^
  main.cpp:9:49: note: candidate: template bool isPrime(const TypeDate&amp;, TypeFunc, bool)
   template&lt;class TypeDate,typename TypeFunc&gt; bool isPrime(const TypeDate&amp; n,TypeFunc fSqrt = NULL,bool debug = false) {
                                                   ^~~~~~~
  main.cpp:9:49: note:   template argument deduction/substitution failed:
  main.cpp:90:23: note:   couldn't deduce template parameter ‘TypeFunc’
    std::cout&lt;&lt;(isPrime(n)?&quot;Positive&quot;:&quot;Negative&quot;)&lt;&lt;'\n';
                         ^
  </code></pre>
  <p>They are basically the same.</p>