Currently the overload of basic_string::replace taking an initializer_list forwards to the overload taking two const _Char* arguments, which does some debug checks, then forwards to the overload taking a const _Char* and a size_type, which repeats the debug checks.
The initializer_list overload can skip the first step and forward straight to the second one. Tested x86_64-linux, committed to trunk.
commit 85653bbebe9545a320ac38a664bec15f1a407150 Author: Jonathan Wakely <jwak...@redhat.com> Date: Wed Jul 13 17:36:57 2016 +0100 Make basic_string::replace forward to different overload * include/bits/basic_string.h [_GLIBCXX_USE_CXX11_ABI] (replace(__const_iterator, __const_iterator, initializer_list<C>)): Forward to different overload. diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 374c985..60e1dbf 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -1912,7 +1912,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 */ basic_string& replace(const_iterator __i1, const_iterator __i2, initializer_list<_CharT> __l) - { return this->replace(__i1, __i2, __l.begin(), __l.end()); } + { return this->replace(__i1, __i2, __l.begin(), __l.size()); } #endif // C++11 private: