File tree Expand file tree Collapse file tree
modules/core/util/include Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,18 +51,21 @@ int GetNumThreads();
5151template <typename T>
5252constexpr std::string_view GetNamespace () {
5353#if defined(_MSC_VER)
54- constexpr auto func = std::string_view{__FUNCSIG__};
54+ constexpr std::string_view func {__FUNCSIG__};
5555 auto start = func.find (" GetNamespace<" ) + 13 ;
5656 for (auto p : {" class " , " struct " , " enum " , " union " })
57- if (func.substr (start).starts_with (p)) start += p.size ();
57+ if (func.substr (start).starts_with (p)) {
58+ start += std::string_view{p}.size ();
59+ break ;
60+ }
5861#else
59- constexpr auto func = std::string_view{__PRETTY_FUNCTION__};
62+ constexpr std::string_view func {__PRETTY_FUNCTION__};
6063 auto start = func.find (" T = " ) + 4 ;
6164#endif
6265 auto end = func.find_first_of (" ;]> ,>" , start);
63- if (end == std::string_view::npos) return {} ;
64- auto ns_end = func .rfind (" ::" , end );
65- return (ns_end != std::string_view::npos && ns_end > start ) ? func .substr (start, ns_end - start ) : std::string_view{};
66+ auto ns = func. substr (start, end - start) ;
67+ auto pos = ns .rfind (" ::" );
68+ return (pos != std::string_view::npos) ? ns .substr (0 , pos ) : std::string_view{};
6669}
6770
6871inline std::shared_ptr<nlohmann::json> InitJSONPtr () { return std::make_shared<nlohmann::json>(); }
You can’t perform that action at this time.
0 commit comments