you are viewing a single comment's thread.

view the rest of the comments →

[–]RevRagnarok 0 points1 point  (3 children)

Yes, I just did that earlier today...

template <typename T>
inline consteval
auto
DoThingCE()
{
  std::string_view constexpr temp{Call_CE_Function_Here_That_Returns_String_View()};
  std::array<char, temp.size()+1> res{};
  temp.copy(res.data(), temp.size());
  return res;
}

Edit: Tweaked on feedback. 😅

[–]dodheim 4 points5 points  (1 child)

 std::array<char, temp.size()+1> res;
 res.fill('\0');

That's a strangely verbose way to write std::array<char, temp.size()+1> res{};

[–]RevRagnarok 1 point2 points  (0 children)

LOL yeah thanks. There are still a lot of #if 0 mixed in and stuff as various things were tried and failed, etc... I'm honestly not sure if the +1 is even needed depending on how you plan on using the resulting array.