Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested std::bind with a custom placeholder fails to compile #51095

Closed
pdimov mannequin opened this issue Sep 5, 2021 · 2 comments
Closed

Nested std::bind with a custom placeholder fails to compile #51095

pdimov mannequin opened this issue Sep 5, 2021 · 2 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Comments

@pdimov
Copy link
Mannequin

pdimov mannequin commented Sep 5, 2021

Bugzilla Link 51753
Version 12.0
OS Windows NT
CC @mclow

Extended Description

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.)

@mclow
Copy link
Contributor

mclow commented Sep 5, 2021

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

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

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@Quuxplusone Quuxplusone self-assigned this Dec 29, 2021
@Quuxplusone
Copy link
Contributor

This is now https://reviews.llvm.org/D116388

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

No branches or pull requests

2 participants