N
Nephi Immortal
I use template to replace assert macro. I don’t have to provide
function parameter list if I want. I use Static_Data class to access
data members through template parameter.
If you set ASSERT to false in either debug mode or release mode, the
code is omitted from inserting into main function.
Is my code OK and readable? I need to change some names to describe
good readability.
static const bool ASSERT = false;
struct Static_Data
{
static const char a = 1;
static const char b = 2;
static const char c = 3;
};
template< typename t_Static_Data >
bool Do()
{
printf( "Assert Message: %d %d %d\n", t_Static_Data::a,
t_Static_Data::b, t_Static_Data::c );
return true;
}
int main()
{
ASSERT && Do< Static_Data >();
return 0;
}
function parameter list if I want. I use Static_Data class to access
data members through template parameter.
If you set ASSERT to false in either debug mode or release mode, the
code is omitted from inserting into main function.
Is my code OK and readable? I need to change some names to describe
good readability.
static const bool ASSERT = false;
struct Static_Data
{
static const char a = 1;
static const char b = 2;
static const char c = 3;
};
template< typename t_Static_Data >
bool Do()
{
printf( "Assert Message: %d %d %d\n", t_Static_Data::a,
t_Static_Data::b, t_Static_Data::c );
return true;
}
int main()
{
ASSERT && Do< Static_Data >();
return 0;
}