1

Does a compiler front end parse templates for enable_if; or is that the responsibility of the back end? I'm trying to understand how enable_if works at the compiler level.

  • 1
    The C++ standard doesn't say anything about these kinds of details; thus, this would be implementation specific. – ChrisMM May 02 '22 at 21:45
  • 3
    `std::enable_if` is not a feature of the compiler or the language itself. It is simply a few lines of C++ code in the standard library, inspired from code distributed as [`boost::enable_if`](https://www.boost.org/doc/libs/1_66_0/libs/core/doc/html/core/enable_if.html#core.enable_if.the_enable_if_templates). – Drew Dormann May 02 '22 at 21:49
  • 1
    Have you already read this: https://stackoverflow.com/questions/25284499/how-does-stdenable-if-work ? – Bob__ May 02 '22 at 22:35
  • It's the responsibility of the middle end :) But Drew's right, there's nothing particularly special about it as templates go, there is a 'possible implementation' over at [cppreference](https://en.cppreference.com/w/cpp/types/enable_if). – Paul Sanders May 02 '22 at 23:29
  • Thanks! I know my question could have been more clear, but the answers provided have given me a different insight on how to tackle the problem I'm trying to solve! – EriktheRook May 03 '22 at 00:12

0 Answers0