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
when
instead ofstd::enable_if
when
is used to control the priority of partial specializations in a finer grained manner than what can be achieved with the usualtypename Enable = void
andstd::enable_if
pattern. 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.