Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • "However, it bothers me" - Why? And please don't say "efficiency". This idiom is very prone to inlining. But even then, you'd be told to measure carefully. Commented Aug 10, 2021 at 11:38
  • 2
    Even solving the overload issue, see can-i-take-the-address-of-a-function-defined-in-standard-library. Commented Aug 10, 2021 at 11:40
  • 1
    @StoryTeller-UnslanderMonica: and passing lambda is even more prone to inlining than function pointer :) Commented Aug 10, 2021 at 11:41
  • 1
    @rprospero: it would be something like static_cast<bool (*)(const std::pair<int, bool>&)>(std::get<bool>) (if allowed for std::get). lambda seems better ;) Commented Aug 10, 2021 at 11:43
  • @StoryTeller-UnslanderMonica honestly, my co-workers all thought that the second version was clearer to read, but the linked answer obviously shows that it's not legal syntax, so our legibility concerns are moot. Commented Aug 10, 2021 at 11:45