I'm working on a generic library class for a collage assignment, and it is very important that the code runs as efficient as possible, that is if we can reduce an if-statement we should do it.
I have the following code which is needed to initialize an array if it is a fundamental type such as double or int.
T b[dim];
if(std::is_fundemental::<T>::value)
{
memset(b, 0, dim*sizeof(T));
}
Now the question is whether this check is optimized out, such that it does not make a runtime check, or do i need to create a template for the initialization with a specialization for fundamental types?
I use G++ with C++11, but it should be able to run without the check on most, preferably all, compilers.