| 957 | // Format list subclass with fixed storage to avoid dynamic allocation |
| 958 | template<int N> |
| 959 | class FormatListN : public FormatList |
| 960 | { |
| 961 | public: |
| 962 | #ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES |
| 963 | template<typename... Args> |
| 964 | FormatListN(const Args&... args) |
| 965 | : FormatList(&m_formatterStore[0], N), |
| 966 | m_formatterStore { FormatArg(args)... } |
| 967 | { static_assert(sizeof...(args) == N, "Number of args must be N"); } |
| 968 | #else // C++98 version |
| 969 | void init(int) {} |
| 970 | # define TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR(n) \ |
| 971 | \ |
| 972 | template<TINYFORMAT_ARGTYPES(n)> \ |
| 973 | FormatListN(TINYFORMAT_VARARGS(n)) \ |
| 974 | : FormatList(&m_formatterStore[0], n) \ |
| 975 | { TINYFORMAT_ASSERT(n == N); init(0, TINYFORMAT_PASSARGS(n)); } \ |
| 976 | \ |
| 977 | template<TINYFORMAT_ARGTYPES(n)> \ |
| 978 | void init(int i, TINYFORMAT_VARARGS(n)) \ |
| 979 | { \ |
| 980 | m_formatterStore[i] = FormatArg(v1); \ |
| 981 | init(i+1 TINYFORMAT_PASSARGS_TAIL(n)); \ |
| 982 | } |
| 983 | |
| 984 | TINYFORMAT_FOREACH_ARGNUM(TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR) |
| 985 | # undef TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR |
| 986 | #endif |
| 987 | FormatListN(const FormatListN& other) |
| 988 | : FormatList(&m_formatterStore[0], N) |
| 989 | { std::copy(&other.m_formatterStore[0], &other.m_formatterStore[N], |
| 990 | &m_formatterStore[0]); } |
| 991 | |
| 992 | private: |
| 993 | FormatArg m_formatterStore[N]; |
| 994 | }; |
| 995 | |
| 996 | // Special 0-arg version - MSVC says zero-sized C array in struct is nonstandard |
| 997 | template<> class FormatListN<0> : public FormatList |
nothing calls this directly
no outgoing calls
no test coverage detected