This change adds the macros _LIBCPP_COMPILER_HAS_BUILTIN_CONSTANT_P and _LIBCPP_BUILTIN_CONSTANT_P to detect compile time constants, and optimze the code accordingly.
A planned usage example:
The implementation of basic_string::assign() can short-cut a compile time known short string assignent into a fast and compact inlined assignment:
basic_string::assign(const value_type* __s) { if (_LIBCPP_BUILTIN_CONSTANT_P(__s[0]) && length(__s) < __min_cap) { copy(pointer(), _s, length(__s) + 1); set_size(length(__s)); } else { // delegate / tail call out of line implementation } }
Just put this in the same block as the other feature check for the same version.