@@ -137,6 +137,10 @@ namespace tfm = tinyformat;
137137#include < iostream>
138138#include < sstream>
139139
140+ #ifndef TINYFORMAT_ASSERT
141+ # define TINYFORMAT_ASSERT (cond ) assert (cond)
142+ #endif
143+
140144#ifndef TINYFORMAT_ERROR
141145# define TINYFORMAT_ERROR (reason ) assert (0 && reason)
142146#endif
@@ -210,7 +214,7 @@ template<int n> struct is_wchar<wchar_t[n]> {};
210214template <typename T, typename fmtT, bool convertible = is_convertible<T, fmtT>::value>
211215struct formatValueAsType
212216{
213- static void invoke (std::ostream& /* out*/ , const T& /* value*/ ) { assert (0 ); }
217+ static void invoke (std::ostream& /* out*/ , const T& /* value*/ ) { TINYFORMAT_ASSERT (0 ); }
214218};
215219// Specialized version for types that can actually be converted to fmtT, as
216220// indicated by the "convertible" template parameter.
@@ -503,15 +507,15 @@ class FormatArg
503507 void format (std::ostream& out, const char * fmtBegin,
504508 const char * fmtEnd, int ntrunc) const
505509 {
506- assert (m_value);
507- assert (m_formatImpl);
510+ TINYFORMAT_ASSERT (m_value);
511+ TINYFORMAT_ASSERT (m_formatImpl);
508512 m_formatImpl (out, fmtBegin, fmtEnd, ntrunc, m_value);
509513 }
510514
511515 int toInt () const
512516 {
513- assert (m_value);
514- assert (m_toIntImpl);
517+ TINYFORMAT_ASSERT (m_value);
518+ TINYFORMAT_ASSERT (m_toIntImpl);
515519 return m_toIntImpl (m_value);
516520 }
517521
@@ -877,18 +881,18 @@ class FormatListN : public FormatList
877881 { static_assert (sizeof ...(args) == N, " Number of args must be N" ); }
878882#else // C++98 version
879883 void init (int ) {}
880- # define TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR (n ) \
881- \
882- template <TINYFORMAT_ARGTYPES (n)> \
883- FormatListN (TINYFORMAT_VARARGS (n)) \
884- : FormatList(&m_formatterStore[0 ], n) \
885- { assert (n == N); init (0 , TINYFORMAT_PASSARGS (n)); } \
886- \
887- template <TINYFORMAT_ARGTYPES (n)> \
888- void init (int i, TINYFORMAT_VARARGS (n)) \
889- { \
890- m_formatterStore[i] = FormatArg (v1); \
891- init (i+1 TINYFORMAT_PASSARGS_TAIL (n)); \
884+ # define TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR (n ) \
885+ \
886+ template <TINYFORMAT_ARGTYPES (n)> \
887+ FormatListN (TINYFORMAT_VARARGS (n)) \
888+ : FormatList(&m_formatterStore[0 ], n) \
889+ { TINYFORMAT_ASSERT (n == N); init (0 , TINYFORMAT_PASSARGS (n)); } \
890+ \
891+ template <TINYFORMAT_ARGTYPES (n)> \
892+ void init (int i, TINYFORMAT_VARARGS (n)) \
893+ { \
894+ m_formatterStore[i] = FormatArg (v1); \
895+ init (i+1 TINYFORMAT_PASSARGS_TAIL (n)); \
892896 }
893897
894898 TINYFORMAT_FOREACH_ARGNUM (TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR )
0 commit comments