Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Fwd: C++

26 views
Skip to first unread message

Vir Campestris

unread,
Jan 4, 2018, 4:53:56 PM1/4/18
to
Given
template <typename T> void bazz(T) {};

Why does
        auto foo = std::bind(bazz, 42);
not deduce the template param? You have to say
        auto foo = std::bind(bazz<int>, 42);

It's probably correct behaviour, but it's a right PITA.

Andy

Alf P. Steinbach

unread,
Jan 4, 2018, 5:49:57 PM1/4/18
to
You can do this, though:

auto foo = [](){ bazz( 42 ); };

Cheers & hth.,

- Alf

Vir Campestris

unread,
Jan 4, 2018, 5:58:10 PM1/4/18
to
This time it doesn't. That's cut down from some code that takes an
argument pack as well, and they don't seem to sit well with lambdas.

BTW Someone at work pointed out to me you can say
auto foo = []{ bazz( 42 ); };
leaving out one set of brackets.

Andy
0 new messages