Skip to content

Commit

Permalink
Merge "protozero: mark constchars as hashable" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Treehugger Robot authored and Gerrit Code Review committed Nov 25, 2024
2 parents 421e518 + 9391393 commit b094411
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/perfetto/protozero/field.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <stdint.h>

#include <string>
#include <string_view>
#include <vector>

#include "perfetto/base/logging.h"
Expand All @@ -41,7 +42,9 @@ struct ConstChars {
// Allow implicit conversion to perfetto's base::StringView without depending
// on perfetto/base or viceversa.
static constexpr bool kConvertibleToStringView = true;
std::string ToStdString() const { return std::string(data, size); }
static constexpr bool kHashable = true;
std::string ToStdString() const { return {data, size}; }
std::string_view ToStdStringView() const { return {data, size}; }

const char* data;
size_t size;
Expand Down

0 comments on commit b094411

Please sign in to comment.