Return an std::string_view
when possible for vk::to_string
functions.
#2092
Labels
std::string_view
when possible for vk::to_string
functions.
#2092
Functions that return the name of plain enums(not bit-flag enums and such that require building a new string of active bits) are just returning pointers to plaintext strings residing in
.rdata
, but they currently requiring allocation of a newstd::string
in all cases:Vulkan-Hpp/vulkan/vulkan_to_string.hpp
Lines 3888 to 3903 in 8f9db1b
These enums in particular could be returning a std::string_view(since C++17) utilizing string-view literals so that the length of the string is known at compile-time rather than costing an additional
strlen
and avoids an additional string-allocation at run-time like so:With this pattern, no additional memory has to be allocated unless the user chooses to cast it to an
std::string
later.The text was updated successfully, but these errors were encountered: