I'm trying to remove the last character of an std string view, but no matter what I do it remains there. I think its because I'm accidentally removing the "/0" instead of the desired "]".
Here is my code:
#include <iostream>#include <tstr/tstring.h>#include <cstring>template<typename Class>constexpr const char* to_string() { std::string_view str = __PRETTY_FUNCTION__; auto first = str.find("= "); auto last = str.find("]"); auto str2 = str.substr(first + 2, last - first + 1); return str2.data();}class Foo {};int main(){ std::cout << to_string<Foo>() << std::endl; return 0;}
This outputs Foo]
. How can I remove the prepending ]
?
Thanks.