Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

More C++ Idioms/Enable if

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

Intent Sometimes a member function of a class template (possibly one of an overloaded set) only makes sense for certain template parameters. The enable_if idiom uses SFINAE to eliminate unwanted functions before overload resolution. Also Known As Motivation Solution and Sample Code Known Uses One use of enable_if is in implementing requirements such as that on the (size_type, value_type) constructor of a standard container, which has special behavior if the value_type is an integral type. More primitive solutions exist, but enable_if is elegant in this context. Related Idioms SFINAE, metafunctions. References