title: "no matching function call to 'bind'" when compiling using the Android NDK
body: <p>I'm trying to port one of my OpenGL applications to Android using the NDK, and I'm hitting a weird compilation error that I just can't figure out!</p>
  
  <p>I have the following template functions to help detect OpenGL errors:</p>
  
  <pre><code>template&lt;typename Res, typename Func, typename... Args&gt;
  struct Checker {
      static Res run(Func&amp;&amp; func, Args&amp;&amp;... args) {
          Res result = std::bind(std::forward&lt;Func&gt;(func), std::forward&lt;Args&gt;(args)...)();
          check_and_log_error("", 0);
          return result;
      }
  };
  
  template&lt;typename Func, typename... Args&gt;
  struct Checker&lt;void, Func, Args...&gt; {
      static void run(Func&amp;&amp; func, Args&amp;&amp;... args) {
          std::bind(std::forward&lt;Func&gt;(func), std::forward&lt;Args&gt;(args)...)();
          check_and_log_error("", 0);
      }
  };
  
  template&lt;typename Func&gt;
  struct Checker&lt;void, Func&gt; {
      static void run(Func&amp;&amp; func) {
          func();
          check_and_log_error("", 0);
      }
  };
  
  }
  
  template&lt;typename Res=void, typename Func, typename... Args&gt;
  Res GLCheck(Func&amp;&amp; func, Args&amp;&amp;... args) {
      GLThreadCheck::check();
      return GLChecker::Checker&lt;Res, Func, Args...&gt;::run(std::forward&lt;Func&gt;(func), std::forward&lt;Args&gt;(args)...);
  }
  </code></pre>
  
  <p>I can then call OpenGL functions like this:</p>
  
  <pre><code>GLCheck(glBindTexture, GL_TEXTURE_2D, gl_tex_);
  </code></pre>
  
  <p>And the application will log an error if that call failed for some reason. This all works fine on the desktop, but when I try to compile for Android, every single OpenGL call gives compilation errors like this:</p>
  
  <pre><code>kglt/kglt/utils/gl_error.h:30:9: error: no matching function for call to 'bind'
          std::bind(std::forward&lt;Func&gt;(func), std::forward&lt;Args&gt;(args)...)();
          ^~~~~~~~~
  kglt/kglt/utils/gl_error.h:48:52: note: in instantiation of member function 'GLChecker::Checker&lt;void, void (&amp;)(unsigned int, unsigned int) __attribute__((pcs("aapcs"))), int, unsigned int &amp;&gt;::run' requested here
      return GLChecker::Checker&lt;Res, Func, Args...&gt;::run(std::forward&lt;Func&gt;(func), std::forward&lt;Args&gt;(args)...);
                                                     ^
  kglt/kglt/texture.cpp:77:5: note: in instantiation of function template specialization 'GLCheck&lt;void, void (&amp;)(unsigned int, unsigned int) __attribute__((pcs("aapcs"))), int, unsigned int &amp;&gt;' requested here
      GLCheck(glBindTexture, GL_TEXTURE_2D, gl_tex_);
      ^
  /home/kazade/Android/android-ndk-r10/sources/cxx-stl/gnu-libstdc++/4.8/include/functional:1682:5: note: candidate template ignored: couldn't infer template argument '_Result'
      bind(_Func&amp;&amp; __f, _BoundArgs&amp;&amp;... __args)
      ^
  /home/kazade/Android/android-ndk-r10/sources/cxx-stl/gnu-libstdc++/4.8/include/functional:1655:5: note: candidate template ignored: substitution failure [with _Func = void (&amp;)(unsigned int, unsigned int) __attribute__((pcs("aapcs"))),
        _BoundArgs = &lt;int, unsigned int &amp;&gt;]
      bind(_Func&amp;&amp; __f, _BoundArgs&amp;&amp;... __args)
  </code></pre>
  
  <p>I can't understand why the template deduction is failing, especially as the "subsitution failure" above seems to show compatible arguments being passed down. The only strange thing that I can see is the <code>__attribute__((pcs("aapcs")))</code> that is part of the OpenGL function.</p>
  
  <p>Can anyone see where the problem is? </p>
  
  <p><em>EDIT: Just saw that the call to bind is entirely pointless, I can call the passed function directly. Even still, I'm curious to know what was causing it to fail anyway :)</em></p>