title: How to infer template parameter "Func" from argument of constructor?
body: <p>My code and problems are as follows:</p>
  
  <pre><code>template &lt;typename T, typename Func&gt; class StepRange {
  public:
    template &lt;
        std::enable_if_t&lt;std::is_invocable_r_v&lt;T, Func, const T &amp;&gt;, int&gt; = 0&gt;
    StepRange(T start, T stop, Func func)
        : start_(std::move(start)), stop_(std::move(stop)), val_(start),
          func_(std::move(func)) {}
    template &lt;typename Step&gt;
    StepRange(T start, T stop, Step step)
        : start_(std::move(start)), stop_(std::move(stop)), val_(start), 
          func_(std::function&lt;T(const T &amp;)&gt;{
            [step](const T &amp;val) { return val + step; }}) {}
  
  private:
    T start_, stop_, val_;
    Func func_;
  };
  
  auto r = StepRange(1, 1, [](int val) { return val + 1;});
  // since c++17 it works fine
  auto t = StepRange(1, 1, 1);
  // it does not compile and compiler says that it couldn't infer template argument 'Func'
  </code></pre>
  
  <p>So how can I use some additional methods to help compiler infer the type of 'Func'?</p>