[llvm-bugs] [Bug 51753] New: Nested std::bind with a custom placeholder fails to compile

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Sep 4 20:44:39 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51753

            Bug ID: 51753
           Summary: Nested std::bind with a custom placeholder fails to
                    compile
           Product: libc++
           Version: 12.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: pdimov at gmail.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

The code
```
#include <functional>

template<int I> struct lambda2_arg
{
};

constexpr lambda2_arg<1> _1{};

namespace std
{

template<int I> struct is_placeholder< lambda2_arg<I> >: integral_constant<int,
I>
{
};

} // namespace std

struct plus_equal
{
    template<class T1, class T2> decltype(auto) operator()(T1&& t1, T2&& t2)
const
    {
        return std::forward<T1>(t1) += std::forward<T2>(t2);
    }
};

struct X
{
    int m;
};

int main()
{
    X x{ 1 };
    return std::bind( plus_equal(), std::bind( &X::m, _1 ), 1 )( x );
}
```
(https://godbolt.org/z/8h1Td56c7)

fails to compile. Other standard libraries work. Using std::placeholders::_1
instead of _1 works.

(This bind expression is produced by Boost.Lambda2.)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210905/10663e7a/attachment.html>


More information about the llvm-bugs mailing list