LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 51753 - Nested std::bind with a custom placeholder fails to compile
Summary: Nested std::bind with a custom placeholder fails to compile
Status: NEW
Alias: None
Product: libc++
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: 12.0
Hardware: PC Windows NT
: P normal
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-04 20:44 PDT by Peter Dimov
Modified: 2021-09-05 07:50 PDT (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Dimov 2021-09-04 20:44:39 PDT
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.)
Comment 1 Marshall Clow (home) 2021-09-05 07:50:56 PDT
This works:
   static_assert (std::is_placeholder<      lambda2_arg<1>>::value, "");

This fails:
   static_assert (std::is_placeholder<const lambda2_arg<1>>::value, "");