| 175 | /// @tparam T A type that will be converted to string |
| 176 | template <typename T> |
| 177 | struct TypeToString |
| 178 | { |
| 179 | #if SC_LANGUAGE_CPP_AT_LEAST_17 |
| 180 | private: |
| 181 | // In C++ 17 we trim the long string producted by ClassName<T> to reduce executable size |
| 182 | [[nodiscard]] static constexpr auto TrimClassName() |
| 183 | { |
| 184 | constexpr auto className = ClNm<T>(); |
| 185 | |
| 186 | ArrayWithSize<char, className.length> trimmedName; |
| 187 | for (uint32_t i = 0; i < className.length; ++i) |
| 188 | { |
| 189 | trimmedName.values[i] = className.data[i]; |
| 190 | } |
| 191 | trimmedName.size = className.length; |
| 192 | return trimmedName; |
| 193 | } |
| 194 | |
| 195 | // Inline static constexpr requires C++17 |
| 196 | static inline constexpr auto value = TrimClassName(); |
| 197 | |
| 198 | public: |
| 199 | [[nodiscard]] static constexpr TypeStringView get() { return TypeStringView(value.values, value.size); } |
| 200 | #else |
| 201 | [[nodiscard]] static constexpr TypeStringView get() |
| 202 | { |
| 203 | auto className = ClNm<T>(); |
| 204 | return TypeStringView(className.data, className.length); |
| 205 | } |
| 206 | #endif |
| 207 | }; |
| 208 | |
| 209 | //! @} |
| 210 |
no outgoing calls
no test coverage detected