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

    • Type: Task
    • Status: Stalled (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Fix Version/s: 10.4, 10.5
    • Component/s: Server
    • Labels:
      None

      Description

      Class is basically:

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

      It should replace all naked char * and const std::string:: & in argument.
      It's 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
            Reporter:
            kevg Eugene Kosov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: