Implementing SFINAE

In this recipe, we will learn how to use Substitution Failure Is Not An Error (SFINAE). This recipe is important because, often, we create templates without ensuring the types passed to a template are what we expect. This can lead to unexpected behavior, suboptimal performance, and even buggy, unreliable code.

SFINAE allows us to be explicit about what types we are expecting in our template. It also provides us with a means to change the behavior of our templates based on the types we are provided. The problem with SFINAE for some is that this concept is difficult to understand. Our goal in this recipe is to demystify SFINAE and show how you can use this in your own code. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset