Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-22438

add a function similar to std::make_scope_exit()

    XMLWordPrintable

Details

    Description

      std::scope_exit is a generic RAII wrapper over any callable (callable class, lambda, function). It calls it's function at the scope end. You can find more information in http://wg21.link/p0052

      A typical usage is freeing resources. Imagine some function where you do malloc() at the beginning and later on free() at three different places before each return;. With scope guard you can just do something like

      auto _ = std::make_scope_guard([ptr]() { free(ptr); });
      

      once soon after allocating and forget about possibly memory leaks.

      Attachments

        Issue Links

          Activity

            People

              kevg Eugene Kosov (Inactive)
              kevg Eugene Kosov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.