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

add class similar to std::string_view (non owning string reference)

    XMLWordPrintable

    Details

      Description

      Class is basically:

      class string_view {
        const char *string;
        size_t length;
      };
      

      It's intended to replace all naked char * and const std::string:: & in functions arguments.
      string_view is better because of a clear semantics: non-owning string. When you see a member or variable const char *smth; you can't say whether it own its buffer or not. For argument you don't know whether ownership was transferred to function or not. Similar to return char * from function.

      string_view makes code easier to read. Also it has begin(), end() member which allows it's data to be used in range-for loops.

      https://en.cppreference.com/w/cpp/string/basic_string_view

        Attachments

          Activity

            People

            Assignee:
            kevg Eugene Kosov (Inactive)
            Reporter:
            kevg Eugene Kosov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.