100DaysOfGameDev: Day 39
I've finally came to the point where I'm quite confident in my C++ knowledge and can to start working on simple projects to test my knowledge on battle. For that reason, I've started following a programming series teaching you to make a ray tracer in a weekend. I have spent most of the time setting up the project. For that I have learned the basics of CMake, although I am not quite happy with my current setup and would modify it in a future. The code is available on my GitHub page, if you'd wanna check it. For now I have followed the introduction and can generate a .ppm (portable pixmap format) with simple red-green gradient image. Here is a preview, although browsers seem not to provide .ppm and instead I converted it to .png.
Finally, I promised you a code snippet from yesterday, which tells true if the template parameter list is homogeneous.
#include <iostream>
template<typename U, typename V>
struct is_same {
static const bool value = false;
};
template<typename U>
struct is_same<U, U> {
static const bool value = true;
};
template<typename First, typename Second, typename... Tail>
struct is_homogeneous {
static const bool value = is_same<First, Second>::value && is_homogeneous<Second, Tail...>::value;
};
template<typename First, typename Second>
struct is_homogeneous<First, Second> {
static const bool value = std::is_same<First, Second>::value;
};
int main ()
{
std::cout << is_homogeneous<int, int, int>::value << std::endl; // gives true
std::cout << is_homogeneous<int, bool, int>::value << std::endl; // gives false
return 0;
}
That's it for today, see you tomorrow!