title: how to create and use own c++ functions instead of library built in ones
body: <p>I have a csharp code which defines two functions Splice and FindIf for lists (already available in C++ for lists). I am trying create both functions for c++ to use without c++ built-in functions. Both csharp and c++ functions are given below</p>
  
  <pre><code>static class ListExtensions
  {
  
      public static void Splice&lt;T&gt;(this List&lt;T&gt; list, int insertAtIndex, List&lt;T&gt; items,
          int first, int last)
      {
          if (items == null) return;
          insertAtIndex = Math.Min(list.Count, Math.Max(0, insertAtIndex));
          first = Math.Min(items.Count - 1, Math.Max(0, first));
          last = Math.Min(items.Count, Math.Max(1, last));
          if (first &gt;= last) return;
  
          list.InsertRange(insertAtIndex, items.GetRange(first, last - first));
          items.RemoveRange(first, last - first);
      }
  
      public static int FindIf&lt;T&gt;(this List&lt;T&gt; list, int start, int end, Func&lt;T, bool&gt; method)
      {
          if (method == null) return end;
          if (!list.Any(method)) return end;
          start = Math.Min(list.Count - 1, Math.Max(0, start));
          end = Math.Min(list.Count, Math.Max(1, end));
          if (start &gt;= end) return end;
  
          List&lt;T&gt; range = list.GetRange(start, end - start);
          int index = range.IndexOf(list.First(method));
          if (index &lt; start) return end;
          return index;
      }
  }
  </code></pre>
  
  <p>Csharp functions are called like below</p>
  
  <pre><code>static bool Move_tokens_to_statement(List&lt;Evl_token&gt; statementTokens, List&lt;Evl_token&gt; tokens)
      {
          Debug.Assert(tokens != null);
  
          int next_sc = tokens.FindIf(0, tokens.Count, TokenIsSemicolon);
  
          if (next_sc == tokens.Count)
          {
              Console.WriteLine("Looked for ';' but reached the end of the file.");
              return false;
          }
  
          ++next_sc;
          statementTokens.Splice(0, tokens, 0, next_sc);
          return true;
      }
  </code></pre>
  
  <p>C++ code I have written to date is given below</p>
  
  <pre><code>template&lt;typename T&gt;
  void Splice(std::list&lt;T&gt; &amp;List, int insertAtIndex, std::list&lt;T&gt; items,
  int first, int last)
  {
      if (items == null) return;
      insertAtIndex = std::min(List.size(), (int)std::max(0, insertAtIndex));
      first = std::min(items.size() - 1, std::max(0, first));
      last = std::min(items.size(), std::max(1, last));
      if (first &gt;= last) return;
      std::copy(first, last-first, std::back_inserter(items));
      List.insert(insertAtIndex, items);
      items.erase(first, last - first);
  };
  
  template&lt;typename T&gt;
  int FindIf(std::list&lt;T&gt; &amp;List, int start, int end, bool(*method)(T))
  {
      if (method == null) return end;
      if (!(std::any_of(List.begin(),List.end(),return method))) return end;
      start = std::min(List.size() - 1, std::max(0, start));;
      end = std::min(List.size(), std::max(1, end));
      if (start &gt;= end) return end;
      list&lt;T&gt; range = std::copy(start, end - start, std::back_inserter(List));    
      int index = range.IndexOf(List.Front(method));
      if (index &lt; start) return end;
      return index;
  };
  </code></pre>
  
  <p>Errors which I see for both c++ defined Splice and FindIf functions are as below</p>
  
  <p>FindIf called on list has error "no instance of FindIf matches the argument list. argument types are ...."</p>
  
  <p>Splice called on list has error "Class std::list .... has no member Splice"</p>
  
  <p>What is best way to define own functions for my code in c++ and what will be solution?</p>