Lemmy: Bestiverse
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
RSS BotMB to Lobste.rsEnglish · 27 days ago

Interconverting std::function with copyable_function

quuxplusone.github.io

external-link
message-square
0
link
fedilink
1
external-link

Interconverting std::function with copyable_function

quuxplusone.github.io

RSS BotMB to Lobste.rsEnglish · 27 days ago
message-square
0
link
fedilink
C++11 introduced std::function as a type-erased callable-object holder. function was badly designed in a few ways: Its rarely used “go fish” API bloats every user; it advertises operator() const even when the controlled object’s operator() is mutating; it handles what should be a precondition violation by throwing an exception, which again bloats every user and means its operator() can never be noexcept. So C++26 fixed these problems by adding std::copyable_function. (Which preserves some of function’s suboptimal design decisions: copyable_function<bool()> remains implicitly convertible to copyable_function<void()>, contextually convertible to bool, and assignable from nullptr.)

Comments

alert-triangle
You must log in or # to comment.

Lobste.rs

lobsters

Subscribe from Remote Instance

You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !lobsters@lemmy.bestiver.se
lock
Community locked: only moderators can create posts. You can still comment on posts.

RSS Feed of lobste.rs

Source of the RSS Bot

Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 49 users / day
  • 177 users / week
  • 416 users / month
  • 1.67K users / 6 months
  • 2 local subscribers
  • 395 subscribers
  • 15.7K Posts
  • 1.08K Comments
  • Modlog
  • mods:
  • patrick
  • RSS Bot
  • BE: 0.19.15
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org