<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - nested std::bind fails to compile"
   href="http://llvm.org/bugs/show_bug.cgi?id=16343">16343</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>nested std::bind fails to compile
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>hhinnant@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>j.arro.2783@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Using libc++, SVN 183522, the nested calls to std::bind in the following code
does not compile:

#include <cmath>
#include <functional>

struct power
{
  template <typename T>
  T
  operator()(T a, T b)
  {
    return std::pow(a, b);
  }
};

struct plus_one
{
  template <typename T>
  T
  operator()(T a)
  {
    return a + 1;
  }
};

int main(int argc, char** argv)
{
  using std::placeholders::_1;

  auto f = std::bind(plus_one(),
    std::bind(power(), 2, _1)
  );

  return f(5);
}

The build output is:

clang++ bind.cpp -std=c++11 -stdlib=libc++ -I
/home/jarryd/current/soft/install/clang/include/c++/v1/ -L
/home/jarryd/current/soft/install/clang/lib/

In file included from bind.cpp:2:
/home/jarryd/current/soft/install/clang/include/c++/v1/functional:1600:49:
error: 
      no type named 'type' in 'std::__1::__invoke_of<const
      std::__1::__bind<power, int, std::__1::placeholders::__ph<1> &> &, int
      &&>'
    typedef typename __invoke_of<_Ti&, _Uj...>::type type;
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
/home/jarryd/current/soft/install/clang/include/c++/v1/functional:1624:14:
note: 
      in instantiation of template class 'std::__1::____mu_return<const
      std::__1::__bind<power, int, std::__1::placeholders::__ph<1> &>, false,
      true, false, std::__1::tuple<int &&> >' requested here
    : public ____mu_return<_Ti,
             ^
/home/jarryd/current/soft/install/clang/include/c++/v1/functional:1650:30:
note: 
      in instantiation of template class 'std::__1::__mu_return<const
      std::__1::__bind<power, int, std::__1::placeholders::__ph<1> &>,
      std::__1::tuple<int &&> >' requested here
                    typename __mu_return<const _BoundArgs, _TupleUj>::ty...
                             ^
/home/jarryd/current/soft/install/clang/include/c++/v1/functional:1654:18:
note: 
      in instantiation of template class 'std::__1::_is_valid_bind_return<const
      plus_one, const std::__1::tuple<std::__1::__bind<power, int,
      std::__1::placeholders::__ph<1> &> >, std::__1::tuple<int &&> >'
requested
      here
          bool = _is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
                 ^
/home/jarryd/current/soft/install/clang/include/c++/v1/functional:1758:18:
note: 
      in instantiation of default argument for '__bind_return<const plus_one,
      const std::__1::tuple<std::__1::__bind<power, int,
      std::__1::placeholders::__ph<1> &> >, std::__1::tuple<int &&> >' required
      here
        typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/jarryd/current/soft/install/clang/include/c++/v1/functional:1759:9: note: 
      while substituting deduced template arguments into function template
      'operator()' [with _Args = <int>]
        operator()(_Args&& ...__args) const
        ^
1 error generated.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>