title: No matching function for call Error using boost::bind
body: <p>I am trying to write a parallel bubblesort function. I am running into an error when using boost::bind:</p>
  
  <pre><code>void swap(vector&lt;int&gt;&amp; input, int i, int j)
  {
      if (input[i] &gt; input[j])
      {   
          int temp = input[j];
          input[j] = input[i];
          input[i] = temp;
      }   
      return;
  }
  
  void parallel_bubblesort(vector&lt;int&gt;&amp; input, int, int)
  {
  
      int i, j, temp;
  
      for (i = 0; i &lt; input.size(); i++)
      {   
          boost::asio::io_service ioService;
          boost::thread_group threadpool;
          for (j = 0; j &lt; input.size() - 1; j++)
          {   
              ioService.post(boost::bind(&amp;swap, boost::ref(input), 2 * j + i % 2, 2 * j + 1 + i % 2));
          }   
  
          for (int t = 0; t &lt; NUM_THREADS; t++)
          {   
              threadpool.create_thread(boost::bind(&amp;boost::asio::io_service::run, &amp;ioService));
          }   
  
          threadpool.join_all();
          ioService.stop();
      }   
      return;
  }
  </code></pre>
  
  <p>It snags on the line</p>
  
  <pre><code>ioService.post(boost::bind(&amp;swap, boost::ref(input), 2 * j + i % 2, 2 * j + 1 + i % 2));
  </code></pre>
  
  <p>The error says</p>
  
  <pre><code>no matching function for call to ‘bind(&lt;unresolved overloaded function type&gt;, std::vector&lt;int, std::allocator&lt;int&gt; &gt;&amp;, int, int)’
  </code></pre>
  
  <p>This seems weird, because none of these are overloaded at all, does anybody know what this means?</p>
  
  <p>Edit: Here is the full program</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;chrono&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;fstream&gt;
  #include &lt;sstream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;algorithm&gt;
  #include &lt;boost/thread.hpp&gt;
  #include &lt;boost/asio/io_service.hpp&gt;
  #define NUM_THREADS 4
  
  using namespace std;
  using namespace boost;
  using namespace boost::this_thread;
  
  int check_solution(const vector&lt;int&gt;&amp;);
  void bubblesort(vector&lt;int&gt;&amp;);
  void swap1(vector&lt;int&gt;&amp;, int, int);
  void parallel_bubblesort(vector&lt;int&gt;&amp;);
  
  int main()
  {
      string line, token;
      string file = "test.txt";
      vector&lt;int&gt; unsorted_integers;
  
      //print out filename
      cout &lt;&lt; file &lt;&lt; endl;
  
      ifstream myfile(file);
  
      //open file
      if(myfile.is_open())
      {   
          //load everything into a vector
          while (getline(myfile, line))
          {   
              int temp;
              std::istringstream ss(line);
              std::getline(ss, token, '\n');
              temp = atoi(token.c_str());
              unsorted_integers.push_back(temp);
          }   
      }   
  
      vector&lt;int&gt; unsorted_integers2(unsorted_integers);
   //starts clock
      std::chrono::high_resolution_clock::time_point start2 = std::chrono::high_resolution_clock::now();
  
      //run the sort function and check for correctness
      parallel_bubblesort(unsorted_integers2);
      if(check_solution(unsorted_integers2))
      {
          cout &lt;&lt; "The parallel sort solution is correct" &lt;&lt; endl;
      }
      else
      {
          cout &lt;&lt; "The parallel sort solution is incorrect" &lt;&lt; endl;
      }
  
      //stops clock and prints times
      std::chrono::high_resolution_clock::time_point end2 = std::chrono::high_resolution_clock::now();
      std::chrono::duration&lt;double&gt; total_time2 = std::chrono::duration_cast&lt;std::chrono::duration&lt;double&gt;&gt;(end2 - start2);
      cout &lt;&lt; "The parallel sort function took " &lt;&lt; total_time2.count() &lt;&lt; " seconds." &lt;&lt; endl;
  
      return 0;
  }
  
  
  void swap1(vector&lt;int&gt;&amp; input, int i, int j)
  {
      if (input[i] &gt; input[j])
      {
          int temp = input[j];
          input[j] = input[i];
          input[i] = temp;
      }
      return;
  }
  
  void parallel_bubblesort(vector&lt;int&gt;&amp; input, int, int)
  {
  
      int i, j;
  
      for (i = 0; i &lt; input.size(); i++)
        {
          boost::asio::io_service ioService;
          boost::thread_group threadpool;
          for (j = 0; j &lt; input.size() - 1; j++)
          {
              ioService.post(boost::bind(&amp;swap1, boost::ref(input), 2 * j + i % 2, 2 * j + 1 + i % 2));
          }
  
          for (int t = 0; t &lt; NUM_THREADS; t++)
          {
              threadpool.create_thread(boost::bind(&amp;boost::asio::io_service::run, &amp;ioService));
          }
  
          threadpool.join_all();
          ioService.stop();
      }
      return;
  }
  
  int check_solution(const vector&lt;int&gt;&amp; solution)
  {
      vector&lt;int&gt; correct_solution(solution);
      std::sort(correct_solution.begin(), correct_solution.end());
      return (solution == correct_solution);
  }
  </code></pre>