https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86471
--- Comment #10 from Matt Bentley <mattreecebentley at gmail dot com> --- (In reply to Marc Glisse from comment #9) > (In reply to Andrew Pinski from comment #7) > We could also use __builtin_constant_p, if the function is inlined often > enough (don't know if it is). Right - so then the proposed function becomes: template<typename _ForwardIterator, typename _Tp> inline typename __gnu_cxx::__enable_if<__is_pointer_helper<_Tp>::__value || __is_integral_helper<_Tp>::__value, void>::__type __fill_a(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { if (__builtin_constant_p(__value) == 1) { if (__value != reinterpret_cast<_Tp>(0)) { const _Tp __tmp = __value; for (; __first != __last; ++__first) *__first = __tmp; } else { if (const size_t __len = __last - __first) __builtin_memset(reinterpret_cast<void *>(__first), 0, __len * sizeof(_Tp)); } } else { const _Tp __tmp = __value; for (; __first != __last; ++__first) *__first = __tmp; } } , if I'm getting the enable_if syntax correct?