I use the following code for restricting a class template argument to be a Plain Old Data type:
template< typename T, typename Enable = void >
struct Vector2;
template< typename T >
struct Vector2< T, typename std::enable_if< std::is_pod< T >::value, void >::type> {
// ...
}
I understand the std::enable_if construct, but I do not understand why I need the "first Vector2" declaration. Of course if I hadn't this one, I couldn't do things like:
using F32x2 = Vector2< F32 >;
But what is the magic behind: typename Enable = void and how is this connected to the "second Vector2" declaration?
↧