Proposal: Allow generic lambdas

35 views
Skip to first unread message

Jeremy Roman

unread,
Jul 31, 2017, 1:56:06 PM7/31/17
to cxx
Chromium now builds in C++14 mode, so I would like to propose that we allow generic lambdas, which use auto (and template type deduction rules) in their argument types. This makes use of lambdas (especially for <algorithm>) more convenient, in the same way that we allow use of auto in range-based for loops. e.g.

before:

std::vector<std::unique_ptr<ExampleWidget>> widgets;
bool widgets_enabled =
    std::all_of(widgets.begin(),
                widgets.end(),
                [](const std::unique_ptr<ExampleWidget>& widget) {
                  return widget->enabled();
                });

after:

std::vector<std::unique_ptr<ExampleWidget>> widgets;
bool widgets_enabled =
    std::all_of(widgets.begin(), widgets.end(), [](const auto& widget) {
      return widget->enabled();
    });

Nico Weber

unread,
Jul 31, 2017, 1:59:40 PM7/31/17
to Jeremy Roman, cxx
No c++14 stuff yet please. I enabled the flag only yesterday (I was hoping nobody would notice), and maybe it'll have to be reverted. I'll send out a note once we're ready for these threads.

--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CACuR13c-nU_%3DHDS2yRhOn3p2XsNie1ceLBxMRCYf1FotgUOvkg%40mail.gmail.com.

Chris Blume

unread,
Jul 31, 2017, 2:13:52 PM7/31/17
to Nico Weber, Jeremy Roman, cxx
I am glad that we are checking our readiness for C++14.

We typically follow Google's style guide and note our differences from it. Google does not yet support C++14. We might be jumping the gun if we adopt C++14 now.

But it is helpful to make sure we are ready for C++14 when the day comes.

Jeremy Roman

unread,
Jul 31, 2017, 2:20:44 PM7/31/17
to Chris Blume, Nico Weber, cxx
On Mon, Jul 31, 2017 at 2:13 PM, Chris Blume <cbl...@google.com> wrote:
I am glad that we are checking our readiness for C++14.

We typically follow Google's style guide and note our differences from it. Google does not yet support C++14. We might be jumping the gun if we adopt C++14 now.

Agreed. I was under the impression that the internal repository did already support C++14, but I apparently made an error in my search query. Withdrawn for now.

dyar...@yandex-team.ru

unread,
Aug 15, 2017, 7:47:29 AM8/15/17
to cxx
Is it OK to revisit this issue now? Consider how much nicer this is than monstrosity we would have to write now.

std::vector<std::unique_ptr<LongClassName::SyncAction>> actions;

std
::sort(actions.begin(), actions.end(),[](const auto& lhs, const auto& rhs) {
 
return lhs->Origin() < rhs->Origin();
});

понедельник, 31 июля 2017 г., 20:56:06 UTC+3 пользователь Jeremy Roman написал:

Jeremy Roman

unread,
Aug 25, 2017, 3:07:55 PM8/25/17
to dyar...@yandex-team.ru, cxx
--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To post to this group, send email to c...@chromium.org.
Reply all
Reply to author
Forward
0 new messages