Allow CreateString invocation with std::string_view#8069
Allow CreateString invocation with std::string_view#8069dbaileychess merged 1 commit intogoogle:masterfrom
Conversation
|
While I like using data() instead of c_str(), note that string view is supported here: // clang-format off
#ifdef FLATBUFFERS_HAS_STRING_VIEW
/// @brief Store a string in the buffer, which can contain any binary data.
/// @param[in] str A const string_view to copy in to the buffer.
/// @return Returns the offset in the buffer where the string starts.
template<template <typename> class OffsetT = Offset>
OffsetT<String>CreateString(flatbuffers::string_view str) {
return CreateString<OffsetT>(str.data(), str.size());
}
#endif // FLATBUFFERS_HAS_STRING_VIEW
// clang-format onHere, the parameter is passed by value (string view style), not const reference (string style) as the code. |
But what if we have struct derived from
Wouldn't this lead to ambig with |
013e820 to
80b2a2e
Compare
|
|
Allow to create strings using
std::string_view