FastLED 3.9.15
Loading...
Searching...
No Matches

◆ getTypeName()

template<typename T>
fl::string fl::test::detail::getTypeName ( )
inline

Definition at line 1751 of file fltest.h.

1751 {
1752#if defined(__clang__) || defined(__GNUC__)
1753 // FL_PRETTY_FUNCTION format: "fl::string fl::test::detail::getTypeName() [T = int]"
1754 const char* func = FL_PRETTY_FUNCTION;
1755 const char* begin = func;
1756 // Find "T = "
1757 while (*begin && !(begin[0] == 'T' && begin[1] == ' ' && begin[2] == '=' && begin[3] == ' '))
1758 ++begin;
1759 if (*begin) {
1760 begin += 4; // Skip "T = "
1761 const char* end = begin;
1762 int depth = 0;
1763 while (*end) {
1764 if (*end == '<') ++depth;
1765 else if (*end == '>') {
1766 if (depth == 0) break;
1767 --depth;
1768 }
1769 else if (*end == ']' && depth == 0) break;
1770 ++end;
1771 }
1772 return fl::string(begin, static_cast<fl::size>(end - begin));
1773 }
1774#elif defined(_MSC_VER)
1775 // FL_PRETTY_FUNCTION format: "class fl::string __cdecl fl::test::detail::getTypeName<int>(void)"
1776 const char* func = FL_PRETTY_FUNCTION;
1777 const char* begin = func;
1778 // Find "getTypeName<"
1779 while (*begin && !(begin[0] == 'g' && begin[1] == 'e' && begin[2] == 't' && begin[3] == 'T' &&
1780 begin[4] == 'y' && begin[5] == 'p' && begin[6] == 'e' && begin[7] == 'N' &&
1781 begin[8] == 'a' && begin[9] == 'm' && begin[10] == 'e' && begin[11] == '<'))
1782 ++begin;
1783 if (*begin) {
1784 begin += 12; // Skip "getTypeName<"
1785 const char* end = begin;
1786 int depth = 1; // We're inside the first <
1787 while (*end && depth > 0) {
1788 if (*end == '<') ++depth;
1789 else if (*end == '>') --depth;
1790 ++end;
1791 }
1792 if (end > begin && depth == 0) --end; // Back up before final >
1793 return fl::string(begin, static_cast<fl::size>(end - begin));
1794 }
1795#endif
1796 return fl::string("{unknown}");
1797}
constexpr T * begin(T(&array)[N]) FL_NOEXCEPT
constexpr T * end(T(&array)[N]) FL_NOEXCEPT
#define FL_PRETTY_FUNCTION

References fl::begin(), fl::end(), FL_NOEXCEPT, FL_PRETTY_FUNCTION, and getTypeName().

Referenced by getTypeName(), and fl::test::detail::TypeNameHolder< T >::name().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: