Enable a partial specialization only if a boolean condition is true.
You might also want to take a look at when_valid, which provides similar functionality but enables a specialziation only when some expression is well-formed.
Rationale for using
wheninstead ofstd::enable_if
whenis used to control the priority of partial specializations in a finer grained manner than what can be achieved with the usualtypename Enable = voidandstd::enable_ifpattern. For example, a partially specialized tag-dispatched method will have a higher priority than an equivalent specialization that useswhen. For more details, see the tutorial section on tag-dispatching.