cpp-common/uuid-view: use string::operator[] instead of string::data to access intern...
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 30 Mar 2023 16:11:19 +0000 (12:11 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 11 Sep 2023 15:24:02 +0000 (11:24 -0400)
commitf442e7c3aa320ac9c76b83c8c18af2339de1f942
tree4222f0706f114ace38d63857da22fcb857f7bf0e
parent8e5571209c1d406db6e5ab4e64a929d952a48d91
cpp-common/uuid-view: use string::operator[] instead of string::data to access internal buffer

Using UuidView::string fails with:

      CXX      ctf-ir.lo
    In file included from /home/smarchi/src/babeltrace/src/cpp-common/bt2/clock-class.hpp:20,
                     from /home/smarchi/src/babeltrace/src/cpp-common/bt2/trace-ir.hpp:19,
                     from /home/smarchi/src/babeltrace/src/plugins/ctf/common/src/metadata/ctf-ir.hpp:18,
                     from /home/smarchi/src/babeltrace/src/plugins/ctf/common/src/metadata/ctf-ir.cpp:8:
    /home/smarchi/src/babeltrace/src/cpp-common/uuid-view.hpp: In member function 'std::string bt2_common::UuidView::str() const':
    /home/smarchi/src/babeltrace/src/cpp-common/uuid-view.hpp:57:38: error: invalid conversion from 'const char*' to 'char*' [-fpermissive]
       57 |         bt_uuid_to_str(_mUuid, s.data());
          |                                ~~~~~~^~
          |                                      |
          |                                      const char*
    In file included from /home/smarchi/src/babeltrace/src/plugins/ctf/common/src/metadata/ctf-ir.hpp:15:
    /home/smarchi/src/babeltrace/src/common/uuid.h:40:62: note:   initializing argument 2 of 'void bt_uuid_to_str(const uint8_t*, char*)'
       40 | BT_HIDDEN void bt_uuid_to_str(const bt_uuid_t uuid_in, char *str_out);
          |                                                        ~~~~~~^~~~~~~

This is because the data method only has a const version in C++11:

  https://en.cppreference.com/w/cpp/string/basic_string/data

It therefore can't be used to modify the content of the string.  Use
operator[] instead.

Change-Id: I3bd9c9756c4e79856a5f0f0c7d8fa14e19c1eadd
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/10805
Tested-by: jenkins <jenkins@lttng.org>
CI-Build: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/cpp-common/uuid-view.hpp
This page took 0.026703 seconds and 4 git commands to generate.