Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Restricting class template argument to PODs

$
0
0
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?

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>