[{"id":1765469,"web_url":"http://patchwork.ozlabs.org/comment/1765469/","msgid":"<20170908155252.GF4582@redhat.com>","list_archive_url":null,"date":"2017-09-08T15:52:52","subject":"Re: [libstdc++/71500] make back reference work with icase","submitter":{"id":48004,"url":"http://patchwork.ozlabs.org/api/people/48004/","name":"Jonathan Wakely","email":"jwakely@redhat.com"},"content":"On 04/09/17 03:31 -0700, Tim Shen via libstdc++ wrote:\n>This fixes the follow-up comments in 71500.\n>\n>Back-reference matching is different from other matching, as the\n>content the back-reference refers to is at \"run-time\", aka during\n>regex_match(), not regex() compilation.\n>\n>For compilation we do have an abstraction layer to catch all\n>comparison customizations, namely _M_translator in regex_compiler.h.\n>Until this patch, we don't have an abstraction for \"run-time\"\n>matching. I believe that back-reference is the only place that needs\n>run-time matching, so I just build a _Backref_matcher in\n>regex_executot.tcc.\n\nLooks like a nice solution. OK for trunk, thanks.\n\nI think this looks safe to backport too, but let's leave it on trunk\nfor a while first.","headers":{"Return-Path":"<gcc-patches-return-461733-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-461733-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"BmqWcT9B\"; dkim-atps=neutral","sourceware.org; auth=none","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=jwakely@redhat.com"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xphg93SZmz9s7f\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  9 Sep 2017 01:53:09 +1000 (AEST)","(qmail 115177 invoked by alias); 8 Sep 2017 15:52:56 -0000","(qmail 115160 invoked by uid 89); 8 Sep 2017 15:52:55 -0000","from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tFri, 08 Sep 2017 15:52:54 +0000","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com\n\t[10.5.11.11])\t(using TLSv1.2 with cipher AECDH-AES256-SHA\n\t(256/256 bits))\t(No client certificate requested)\tby\n\tmx1.redhat.com (Postfix) with ESMTPS id 923914E909;\n\tFri,  8 Sep 2017 15:52:53 +0000 (UTC)","from localhost (unknown [10.33.36.109])\tby smtp.corp.redhat.com\n\t(Postfix) with ESMTP id 46D58600C2;\n\tFri,  8 Sep 2017 15:52:53 +0000 (UTC)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; q=dns; s=default; b=BegnjH2hgNfoGTRzA\n\tG2w3RY3rGhfN1QqWM8PT4NRfxaiR3CMla70M9LkXb6O86QQJ1IKrdkS8ve5L9F8R\n\tme40/ptM/3xnRGARFRmHosfSG/imme6dUmNvtLRTMZ8xDXBPG0Tn6kli63VTxlAa\n\txZccGubQ8xJEuoRqQqOwaQZiAA=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; s=default; bh=hXmCAvQR0fhAgG99+Nthww5\n\t7RcA=; b=BmqWcT9BcSudQbhbwtNx3MhuMpBqgEe+IIUEw+R/sCF9bCiyMZiqkfK\n\tAgvWOA8w0D6fM09tNAvIHs4r40QVZer5DOdpPQdJ+NYsEhq6pE12+XrjJDYn7MLI\n\tF2UhzsFfcwarUMfpkTSxn6L+xYdAptf7NDuLLljPXVTfvEYhq2YI=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-1.9 required=5.0 tests=BAYES_00,\n\tRP_MATCHES_RCVD,\n\tSPF_HELO_PASS autolearn=ham version=3.3.2 spammy=shen, Shen","X-Spam-User":"qpsmtpd, 2 recipients","X-HELO":"mx1.redhat.com","DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 923914E909","Date":"Fri, 8 Sep 2017 16:52:52 +0100","From":"Jonathan Wakely <jwakely@redhat.com>","To":"Tim Shen <timshen@google.com>","Cc":"libstdc++ <libstdc++@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>","Subject":"Re: [libstdc++/71500] make back reference work with icase","Message-ID":"<20170908155252.GF4582@redhat.com>","References":"<CAG4ZjN=teuigpysiMSm+tE+3S4dm+WM=7n7A80gXBDFpdqfhBQ@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii; format=flowed","Content-Disposition":"inline","In-Reply-To":"<CAG4ZjN=teuigpysiMSm+tE+3S4dm+WM=7n7A80gXBDFpdqfhBQ@mail.gmail.com>","X-Clacks-Overhead":"GNU Terry Pratchett","User-Agent":"Mutt/1.8.3 (2017-05-23)"}},{"id":1769265,"web_url":"http://patchwork.ozlabs.org/comment/1769265/","msgid":"<20170915153954.GH4582@redhat.com>","list_archive_url":null,"date":"2017-09-15T15:39:54","subject":"Re: [libstdc++/71500] make back reference work with icase","submitter":{"id":48004,"url":"http://patchwork.ozlabs.org/api/people/48004/","name":"Jonathan Wakely","email":"jwakely@redhat.com"},"content":"On 04/09/17 03:31 -0700, Tim Shen via libstdc++ wrote:\n>This fixes the follow-up comments in 71500.\n>\n>Back-reference matching is different from other matching, as the\n>content the back-reference refers to is at \"run-time\", aka during\n>regex_match(), not regex() compilation.\n>\n>For compilation we do have an abstraction layer to catch all\n>comparison customizations, namely _M_translator in regex_compiler.h.\n>Until this patch, we don't have an abstraction for \"run-time\"\n>matching. I believe that back-reference is the only place that needs\n>run-time matching, so I just build a _Backref_matcher in\n>regex_executot.tcc.\n>\n>Tested on x86_64-linux-gnu.\n>\n>Thanks!\n>\n>-- \n>Regards,\n>Tim Shen\n\n>commit a97b7fecd319e031ffc489a956b8cf3dc63eeb26\n>Author: Tim Shen <timshen@google.com>\n>Date:   Mon Sep 4 03:19:35 2017 -0700\n>\n>            PR libstdc++/71500\n>            * include/bits/regex_executor.tcc: Support icase in\n>            regex_tratis<...> for back reference matches.\n>            * testsuite/28_regex/regression.cc: Test case.\n>\n>diff --git a/libstdc++-v3/include/bits/regex_executor.tcc b/libstdc++-v3/include/bits/regex_executor.tcc\n>index 226e05856e1..f6149fecf9d 100644\n>--- a/libstdc++-v3/include/bits/regex_executor.tcc\n>+++ b/libstdc++-v3/include/bits/regex_executor.tcc\n>@@ -335,6 +335,54 @@ namespace __detail\n> \t  _M_states._M_queue(__state._M_next, _M_cur_results);\n>     }\n> \n>+  template<typename _BiIter, typename _TraitsT>\n>+    struct _Backref_matcher\n>+    {\n>+      _Backref_matcher(bool __icase, const _TraitsT& __traits)\n>+      : _M_traits(__traits) { }\n>+\n>+      bool\n>+      _M_apply(_BiIter __expected_begin,\n>+\t       _BiIter __expected_end, _BiIter __actual_begin,\n>+\t       _BiIter __actual_end)\n>+      {\n>+\treturn _M_traits.transform(__expected_begin, __expected_end)\n>+\t    == _M_traits.transform(__actual_begin, __actual_end);\n>+      }\n>+\n>+      const _TraitsT& _M_traits;\n>+    };\n>+\n>+  template<typename _BiIter, typename _CharT>\n>+    struct _Backref_matcher<_BiIter, std::regex_traits<_CharT>>\n>+    {\n>+      using _TraitsT = std::regex_traits<_CharT>;\n>+      _Backref_matcher(bool __icase, const _TraitsT& __traits)\n>+      : _M_icase(__icase), _M_traits(__traits) { }\n>+\n>+      bool\n>+      _M_apply(_BiIter __expected_begin,\n>+\t       _BiIter __expected_end, _BiIter __actual_begin,\n>+\t       _BiIter __actual_end)\n>+      {\n>+\tif (!_M_icase)\n>+\t  return std::equal(__expected_begin, __expected_end,\n>+\t\t\t    __actual_begin, __actual_end);\n\nThis is only valid in C++14 and higher, because the 4-argument version\nof std::equal isn't present in C++11.\n\n>+\ttypedef std::ctype<_CharT> __ctype_type;\n>+\tconst auto& __fctyp = use_facet<__ctype_type>(_M_traits.getloc());\n>+\treturn std::equal(__expected_begin, __expected_end,\n>+\t\t\t  __actual_begin, __actual_end,\n\nSame here.\n\n>+\t\t\t  [this, &__fctyp](_CharT __lhs, _CharT __rhs)\n>+\t\t\t  {\n>+\t\t\t    return __fctyp.tolower(__lhs)\n>+\t\t\t\t== __fctyp.tolower(__rhs);\n>+\t\t\t  });\n\nWe need to rewrite this to check the lengths are equal first, and then\ncall the 3-argument version of std::equal.\n\nAlternatively, we could move the implementation of the C++14\nstd::equal overloads to __equal and make that available for C++11.\nI'll try that.","headers":{"Return-Path":"<gcc-patches-return-462265-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462265-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"c0Sov77z\"; dkim-atps=neutral","sourceware.org; auth=none","ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx04.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=jwakely@redhat.com"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xv03D2ML4z9sPr\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 16 Sep 2017 01:40:24 +1000 (AEST)","(qmail 31648 invoked by alias); 15 Sep 2017 15:39:58 -0000","(qmail 31505 invoked by uid 89); 15 Sep 2017 15:39:58 -0000","from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tFri, 15 Sep 2017 15:39:56 +0000","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com\n\t[10.5.11.14])\t(using TLSv1.2 with cipher AECDH-AES256-SHA\n\t(256/256 bits))\t(No client certificate requested)\tby\n\tmx1.redhat.com (Postfix) with ESMTPS id 73EB980463;\n\tFri, 15 Sep 2017 15:39:55 +0000 (UTC)","from localhost (unknown [10.33.36.48])\tby smtp.corp.redhat.com\n\t(Postfix) with ESMTP id 296AC5D736;\n\tFri, 15 Sep 2017 15:39:55 +0000 (UTC)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; q=dns; s=default; b=HFcbdPNxiXpmAZhLS\n\trZcck3BCLK2GkMqFuXmsHKIfM71aeuqW+1gRslppjQma4JMtZZkHQnDJ99VIBxXZ\n\tVkq8gC26kPxYPpg2zK/6ImtqnKCcD6DUI57xjKa8lExsZFF5HkBJRaHwpflBMfoT\n\tK4+qm9Ut4htDcHmODgpUOF9RsA=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; s=default; bh=CMVa2eas5qHHlQAza2xBqZR\n\tJSTU=; b=c0Sov77z1Tyn6z4eqmuZagCS5AC20+HbeMzX/QQjIj/1YlSVNSXPK7a\n\tXihLCvjRjdxzk+tRYcd9OhxO7hJinsUnJo15wADWTdNlBM/v6cJoxS1b6P6uY4Zd\n\tI0ZbFOUjhlQ5QGE0QoMt3rVYWi5hkjOKpygI+zuI4zjC7csVYWCI=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD,\n\tSPF_HELO_PASS autolearn=ham version=3.3.2 spammy=","X-Spam-User":"qpsmtpd, 2 recipients","X-HELO":"mx1.redhat.com","DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 73EB980463","Date":"Fri, 15 Sep 2017 16:39:54 +0100","From":"Jonathan Wakely <jwakely@redhat.com>","To":"Tim Shen <timshen@google.com>","Cc":"libstdc++ <libstdc++@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>","Subject":"Re: [libstdc++/71500] make back reference work with icase","Message-ID":"<20170915153954.GH4582@redhat.com>","References":"<CAG4ZjN=teuigpysiMSm+tE+3S4dm+WM=7n7A80gXBDFpdqfhBQ@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii; format=flowed","Content-Disposition":"inline","In-Reply-To":"<CAG4ZjN=teuigpysiMSm+tE+3S4dm+WM=7n7A80gXBDFpdqfhBQ@mail.gmail.com>","X-Clacks-Overhead":"GNU Terry Pratchett","User-Agent":"Mutt/1.8.3 (2017-05-23)"}},{"id":1770358,"web_url":"http://patchwork.ozlabs.org/comment/1770358/","msgid":"<20170918172617.GI4582@redhat.com>","list_archive_url":null,"date":"2017-09-18T17:26:17","subject":"Re: [libstdc++/71500] make back reference work with icase","submitter":{"id":48004,"url":"http://patchwork.ozlabs.org/api/people/48004/","name":"Jonathan Wakely","email":"jwakely@redhat.com"},"content":"On 15/09/17 16:39 +0100, Jonathan Wakely wrote:\n>On 04/09/17 03:31 -0700, Tim Shen via libstdc++ wrote:\n>>This fixes the follow-up comments in 71500.\n>>\n>>Back-reference matching is different from other matching, as the\n>>content the back-reference refers to is at \"run-time\", aka during\n>>regex_match(), not regex() compilation.\n>>\n>>For compilation we do have an abstraction layer to catch all\n>>comparison customizations, namely _M_translator in regex_compiler.h.\n>>Until this patch, we don't have an abstraction for \"run-time\"\n>>matching. I believe that back-reference is the only place that needs\n>>run-time matching, so I just build a _Backref_matcher in\n>>regex_executot.tcc.\n>>\n>>Tested on x86_64-linux-gnu.\n>>\n>>Thanks!\n>>\n>>-- \n>>Regards,\n>>Tim Shen\n>\n>>commit a97b7fecd319e031ffc489a956b8cf3dc63eeb26\n>>Author: Tim Shen <timshen@google.com>\n>>Date:   Mon Sep 4 03:19:35 2017 -0700\n>>\n>>           PR libstdc++/71500\n>>           * include/bits/regex_executor.tcc: Support icase in\n>>           regex_tratis<...> for back reference matches.\n>>           * testsuite/28_regex/regression.cc: Test case.\n>>\n>>diff --git a/libstdc++-v3/include/bits/regex_executor.tcc b/libstdc++-v3/include/bits/regex_executor.tcc\n>>index 226e05856e1..f6149fecf9d 100644\n>>--- a/libstdc++-v3/include/bits/regex_executor.tcc\n>>+++ b/libstdc++-v3/include/bits/regex_executor.tcc\n>>@@ -335,6 +335,54 @@ namespace __detail\n>>\t  _M_states._M_queue(__state._M_next, _M_cur_results);\n>>    }\n>>\n>>+  template<typename _BiIter, typename _TraitsT>\n>>+    struct _Backref_matcher\n>>+    {\n>>+      _Backref_matcher(bool __icase, const _TraitsT& __traits)\n>>+      : _M_traits(__traits) { }\n>>+\n>>+      bool\n>>+      _M_apply(_BiIter __expected_begin,\n>>+\t       _BiIter __expected_end, _BiIter __actual_begin,\n>>+\t       _BiIter __actual_end)\n>>+      {\n>>+\treturn _M_traits.transform(__expected_begin, __expected_end)\n>>+\t    == _M_traits.transform(__actual_begin, __actual_end);\n>>+      }\n>>+\n>>+      const _TraitsT& _M_traits;\n>>+    };\n>>+\n>>+  template<typename _BiIter, typename _CharT>\n>>+    struct _Backref_matcher<_BiIter, std::regex_traits<_CharT>>\n>>+    {\n>>+      using _TraitsT = std::regex_traits<_CharT>;\n>>+      _Backref_matcher(bool __icase, const _TraitsT& __traits)\n>>+      : _M_icase(__icase), _M_traits(__traits) { }\n>>+\n>>+      bool\n>>+      _M_apply(_BiIter __expected_begin,\n>>+\t       _BiIter __expected_end, _BiIter __actual_begin,\n>>+\t       _BiIter __actual_end)\n>>+      {\n>>+\tif (!_M_icase)\n>>+\t  return std::equal(__expected_begin, __expected_end,\n>>+\t\t\t    __actual_begin, __actual_end);\n>\n>This is only valid in C++14 and higher, because the 4-argument version\n>of std::equal isn't present in C++11.\n>\n>>+\ttypedef std::ctype<_CharT> __ctype_type;\n>>+\tconst auto& __fctyp = use_facet<__ctype_type>(_M_traits.getloc());\n>>+\treturn std::equal(__expected_begin, __expected_end,\n>>+\t\t\t  __actual_begin, __actual_end,\n>\n>Same here.\n>\n>>+\t\t\t  [this, &__fctyp](_CharT __lhs, _CharT __rhs)\n>>+\t\t\t  {\n>>+\t\t\t    return __fctyp.tolower(__lhs)\n>>+\t\t\t\t== __fctyp.tolower(__rhs);\n>>+\t\t\t  });\n>\n>We need to rewrite this to check the lengths are equal first, and then\n>call the 3-argument version of std::equal.\n>\n>Alternatively, we could move the implementation of the C++14\n>std::equal overloads to __equal and make that available for C++11.\n>I'll try that.\n\nHere's a proof of concept patch for that. It's a bit ugly.\ndiff --git a/libstdc++-v3/include/bits/regex_executor.tcc b/libstdc++-v3/include/bits/regex_executor.tcc\nindex f6149fecf9d..4b185cc9d1e 100644\n--- a/libstdc++-v3/include/bits/regex_executor.tcc\n+++ b/libstdc++-v3/include/bits/regex_executor.tcc\n@@ -366,17 +366,21 @@ namespace __detail\n \t       _BiIter __actual_end)\n       {\n \tif (!_M_icase)\n-\t  return std::equal(__expected_begin, __expected_end,\n-\t\t\t    __actual_begin, __actual_end);\n+\t  return std::__equal4(__expected_begin, __expected_end,\n+\t\t\t       __actual_begin, __actual_end,\n+\t\t\t       std::__iterator_category(__expected_begin),\n+\t\t\t       std::__iterator_category(__actual_begin));\n \ttypedef std::ctype<_CharT> __ctype_type;\n \tconst auto& __fctyp = use_facet<__ctype_type>(_M_traits.getloc());\n-\treturn std::equal(__expected_begin, __expected_end,\n-\t\t\t  __actual_begin, __actual_end,\n-\t\t\t  [this, &__fctyp](_CharT __lhs, _CharT __rhs)\n-\t\t\t  {\n-\t\t\t    return __fctyp.tolower(__lhs)\n-\t\t\t\t== __fctyp.tolower(__rhs);\n-\t\t\t  });\n+\treturn std::__equal4_p(__expected_begin, __expected_end,\n+\t\t\t       __actual_begin, __actual_end,\n+\t\t\t       [this, &__fctyp](_CharT __lhs, _CharT __rhs)\n+\t\t\t       {\n+\t\t\t\t return __fctyp.tolower(__lhs)\n+\t\t\t\t   == __fctyp.tolower(__rhs);\n+\t\t\t       },\n+\t\t\t       std::__iterator_category(__expected_begin),\n+\t\t\t       std::__iterator_category(__actual_begin));\n       }\n \n       bool _M_icase;\ndiff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h\nindex f68ecb22b82..b7848b3de99 100644\n--- a/libstdc++-v3/include/bits/stl_algobase.h\n+++ b/libstdc++-v3/include/bits/stl_algobase.h\n@@ -1082,6 +1082,59 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO\n       return true;\n     }\n \n+#if __cplusplus >= 201103L\n+  template<typename _II1, typename _II2>\n+    inline bool\n+    __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2,\n+\t     random_access_iterator_tag, random_access_iterator_tag)\n+    {\n+      auto __d1 = std::distance(__first1, __last1);\n+      auto __d2 = std::distance(__first2, __last2);\n+      if (__d1 != __d2)\n+\treturn false;\n+      return _GLIBCXX_STD_A::equal(__first1, __last1, __first2);\n+    }\n+\n+  template<typename _II1, typename _II2, typename _Cat1, typename _Cat2>\n+    inline bool\n+    __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2,\n+\t     _Cat1, _Cat2)\n+    {\n+      for (; __first1 != __last1 && __first2 != __last2;\n+\t  ++__first1, (void)++__first2)\n+\tif (!(*__first1 == *__first2))\n+\t  return false;\n+      return __first1 == __last1 && __first2 == __last2;\n+    }\n+\n+  template<typename _II1, typename _II2, typename _BinaryPredicate>\n+    inline bool\n+    __equal4_p(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2,\n+\t       _BinaryPredicate __binary_pred, random_access_iterator_tag,\n+\t       random_access_iterator_tag)\n+    {\n+      auto __d1 = std::distance(__first1, __last1);\n+      auto __d2 = std::distance(__first2, __last2);\n+      if (__d1 != __d2)\n+\treturn false;\n+      return _GLIBCXX_STD_A::equal(__first1, __last1, __first2,\n+\t\t\t\t   __binary_pred);\n+    }\n+\n+  template<typename _II1, typename _II2, typename _BinaryPredicate,\n+\t   typename _Cat1, typename _Cat2>\n+    inline bool\n+    __equal4_p(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2,\n+\t       _BinaryPredicate __binary_pred, _Cat1, _Cat2)\n+    {\n+      for (; __first1 != __last1 && __first2 != __last2;\n+\t  ++__first1, (void)++__first2)\n+\tif (!bool(__binary_pred(*__first1, *__first2)))\n+\t  return false;\n+      return __first1 == __last1 && __first2 == __last2;\n+    }\n+#endif // C++11\n+\n #if __cplusplus > 201103L\n \n #define __cpp_lib_robust_nonmodifying_seq_ops 201304\n@@ -1112,24 +1165,9 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO\n       __glibcxx_requires_valid_range(__first1, __last1);\n       __glibcxx_requires_valid_range(__first2, __last2);\n \n-      using _RATag = random_access_iterator_tag;\n-      using _Cat1 = typename iterator_traits<_II1>::iterator_category;\n-      using _Cat2 = typename iterator_traits<_II2>::iterator_category;\n-      using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;\n-      if (_RAIters())\n-\t{\n-\t  auto __d1 = std::distance(__first1, __last1);\n-\t  auto __d2 = std::distance(__first2, __last2);\n-\t  if (__d1 != __d2)\n-\t    return false;\n-\t  return _GLIBCXX_STD_A::equal(__first1, __last1, __first2);\n-\t}\n-\n-      for (; __first1 != __last1 && __first2 != __last2;\n-\t  ++__first1, (void)++__first2)\n-\tif (!(*__first1 == *__first2))\n-\t  return false;\n-      return __first1 == __last1 && __first2 == __last2;\n+      return _GLIBCXX_STD_A::__equal4(__first1, __last1, __first2, __last2,\n+\t\t\t\t      __iterator_category(__first1),\n+\t\t\t\t      __iterator_category(__first2));\n     }\n \n   /**\n@@ -1159,27 +1197,12 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO\n       __glibcxx_requires_valid_range(__first1, __last1);\n       __glibcxx_requires_valid_range(__first2, __last2);\n \n-      using _RATag = random_access_iterator_tag;\n-      using _Cat1 = typename iterator_traits<_IIter1>::iterator_category;\n-      using _Cat2 = typename iterator_traits<_IIter2>::iterator_category;\n-      using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;\n-      if (_RAIters())\n-\t{\n-\t  auto __d1 = std::distance(__first1, __last1);\n-\t  auto __d2 = std::distance(__first2, __last2);\n-\t  if (__d1 != __d2)\n-\t    return false;\n-\t  return _GLIBCXX_STD_A::equal(__first1, __last1, __first2,\n-\t\t\t\t       __binary_pred);\n-\t}\n-\n-      for (; __first1 != __last1 && __first2 != __last2;\n-\t  ++__first1, (void)++__first2)\n-\tif (!bool(__binary_pred(*__first1, *__first2)))\n-\t  return false;\n-      return __first1 == __last1 && __first2 == __last2;\n+      return _GLIBCXX_STD_A::__equal4_p(__first1, __last1, __first2, __last2,\n+\t\t\t\t\t__binary_pred,\n+\t\t\t\t\t__iterator_category(__first1),\n+\t\t\t\t\t__iterator_category(__first2));\n     }\n-#endif\n+#endif // C++14\n \n   /**\n    *  @brief Performs @b dictionary comparison on ranges.","headers":{"Return-Path":"<gcc-patches-return-462415-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462415-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"sE4EsQxH\"; dkim-atps=neutral","sourceware.org; auth=none","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=jwakely@redhat.com"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xwtGX4bbFz9s7M\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 03:26:43 +1000 (AEST)","(qmail 9046 invoked by alias); 18 Sep 2017 17:26:23 -0000","(qmail 9013 invoked by uid 89); 18 Sep 2017 17:26:21 -0000","from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tMon, 18 Sep 2017 17:26:19 +0000","from smtp.corp.redhat.com\n\t(int-mx02.intmail.prod.int.phx2.redhat.com\n\t[10.5.11.12])\t(using TLSv1.2 with cipher AECDH-AES256-SHA\n\t(256/256 bits))\t(No client certificate requested)\tby\n\tmx1.redhat.com (Postfix) with ESMTPS id A7E6E2CE901;\n\tMon, 18 Sep 2017 17:26:18 +0000 (UTC)","from localhost (unknown [10.33.36.48])\tby smtp.corp.redhat.com\n\t(Postfix) with ESMTP id 2CD5D1880D;\n\tMon, 18 Sep 2017 17:26:18 +0000 (UTC)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; q=dns; s=default; b=xrsaB+bsRTDpOaSTM\n\tty44S1uL8qm6MMACxbM3z1zmnnDtWc7HoOCwD2jy5ZBs112+2P3ZpzA+VVn/sye7\n\tnWIno/MMVSYdqxEk5R2qcEhQzElYmyEWNwcTLUPTNiRns+aZ3fXi2xA8/MLiopf4\n\tD5vyNSjXnJELLqBi8v9jYiuhR8=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; s=default; bh=5C3Qejm0+yodq4zHfGNFnJi\n\thHGw=; b=sE4EsQxHHPaY0LuJaKK0tBeeaIohJBb+sHnpuQTMa7xevp6fQcX+fs8\n\tSi7WjAxUNHKS2/ETmPSjJ9A/v8l66hXFQ7SwUngEiDzTMAegzF8kFo7Jiuen0Qa0\n\tn4hwP+pjhes70JfuGWN1ea4oJNhCEmOipgrQ1NvVtXXOFs60iyvY=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD,\n\tSPF_HELO_PASS autolearn=ham version=3.3.2 spammy=","X-Spam-User":"qpsmtpd, 2 recipients","X-HELO":"mx1.redhat.com","DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com A7E6E2CE901","Date":"Mon, 18 Sep 2017 18:26:17 +0100","From":"Jonathan Wakely <jwakely@redhat.com>","To":"Tim Shen <timshen@google.com>","Cc":"libstdc++ <libstdc++@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>","Subject":"Re: [libstdc++/71500] make back reference work with icase","Message-ID":"<20170918172617.GI4582@redhat.com>","References":"<CAG4ZjN=teuigpysiMSm+tE+3S4dm+WM=7n7A80gXBDFpdqfhBQ@mail.gmail.com>\n\t<20170915153954.GH4582@redhat.com>","MIME-Version":"1.0","Content-Type":"multipart/mixed; boundary=\"00sTfE/IIAT5d2r5\"","Content-Disposition":"inline","In-Reply-To":"<20170915153954.GH4582@redhat.com>","X-Clacks-Overhead":"GNU Terry Pratchett","User-Agent":"Mutt/1.8.3 (2017-05-23)"}},{"id":1770379,"web_url":"http://patchwork.ozlabs.org/comment/1770379/","msgid":"<CAG4ZjN=ioGfbwB+95ns=MaOAP0++UP9ZLwzex1fGcU7+DSxWMQ@mail.gmail.com>","list_archive_url":null,"date":"2017-09-18T17:58:04","subject":"Re: [libstdc++/71500] make back reference work with icase","submitter":{"id":70597,"url":"http://patchwork.ozlabs.org/api/people/70597/","name":"Li, Pan2 via Gcc-patches","email":"gcc-patches@gcc.gnu.org"},"content":"On Mon, Sep 18, 2017 at 10:26 AM, Jonathan Wakely <jwakely@redhat.com> wrote:\n>> We need to rewrite this to check the lengths are equal first, and then\n>> call the 3-argument version of std::equal.\n>>\n>> Alternatively, we could move the implementation of the C++14\n>> std::equal overloads to __equal and make that available for C++11.\n>> I'll try that.\n>\n>\n> Here's a proof of concept patch for that. It's a bit ugly.\n\nInstead of having iterator tags in the interface, we can probe the\nrandom-access-ness inside __equal4/__equal4_p, can't we? It's similar\nto the existing \"if (_RAIters()) { ... }\".\n\nI'd expect the patches to be renaming the current implementations and\nadding wrappers, instead of adding new implementations.","headers":{"Return-Path":"<gcc-patches-return-462423-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462423-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"jwjOCeAg\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xwtz36xKhz9s7c\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 03:58:23 +1000 (AEST)","(qmail 3878 invoked by alias); 18 Sep 2017 17:58:08 -0000","(qmail 3859 invoked by uid 89); 18 Sep 2017 17:58:07 -0000","from mail-pf0-f180.google.com (HELO mail-pf0-f180.google.com)\n\t(209.85.192.180) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tMon, 18 Sep 2017 17:58:06 +0000","by mail-pf0-f180.google.com with SMTP id n24so616658pfk.5 for\n\t<gcc-patches@gcc.gnu.org>; Mon, 18 Sep 2017 10:58:06 -0700 (PDT)","by 10.100.178.164 with HTTP; Mon, 18 Sep 2017 10:58:04 -0700 (PDT)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:in-reply-to:references:from:reply-to:date\n\t:message-id:subject:to:cc:content-type; q=dns; s=default; b=o44b\n\tkjMrj7mBJTyMcb1lH1dLBaf/WztX45+3fK22ixIrsSH0lq/sHWzLyR9KaCnUVh8x\n\tAiZYQWkJmm6zYq4S6yYvIb03JcBufec2nay2a1Gl6bpB9o0V7ozJph+u3x/IyX0j\n\tH3iEjzIkjSidDeab+0dt7K24xMYPil3tbV5wh/k=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:in-reply-to:references:from:reply-to:date\n\t:message-id:subject:to:cc:content-type; s=default; bh=hXxdPwnHxD\n\toubqDfDnN//YD+KdI=; b=jwjOCeAgIFXp3uHJcEK52axS+mKQJHUMvSV0T3uMwl\n\tKgpO5GhEChBQ0tLZG22Z2NiG8SlRchOqgDDtr857Uok4nWivPIW38yZnBeVYTTQT\n\tOIy00PaIMxNGNIGsc9pjdbb2eZ4GuFMiuVvbdBk1H6m6aAizYicxV+r1GTn2ntgR\n\tM=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-1.9 required=5.0 tests=BAYES_00,\n\tRCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=","X-HELO":"mail-pf0-f180.google.com","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net;\n\ts=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=VMjmGfepJc5v6TCD2NxK95XSeBDeUrw5GTWKBrpXuD8=;\n\tb=M0zriNS0r0v8kvgyN8bI4hCkjzuXg020RZ/Q278vGGVd+iEaQGARV2g4oGbttJVxrI\n\tOiJLext67mcdlbqEQy+3xyCNC7VahBWC/dnax3TThG9d/fVO4HwCGA9/5aPT4Ac7OBTw\n\tprtz3p4OQYEPidbq4FcqASQqIfLDecNBkw8bBvZ2Ypjgm9i3SA08ACzdG9Gm3cZfZmmA\n\tdhzXRCruypUH05DIlvc8EAcZTGsNDVy0neoazqL23H+vutyRcHlqZy1BpU78YXvltG2/\n\tO6uUhixCaid0F795kMINDoSvXsGdopT3tR1EvXM/1Yjs9NM6H7n6gsKS35b55TUyu9Ju\n\tPRjQ==","X-Gm-Message-State":"AHPjjUiiUcV0haNwqFL/TPhZMQiaFY95kNCtkVHxo06UYKOYA3cDVN/m\tvZ96v6iEu/oq8EPkoQ2dhWCjiEbYX33RuWFyd71UDA==","X-Google-Smtp-Source":"AOwi7QBrf0os/4QfWx/VeowqH/J5gxos4I4h7HHDW7NHajSN20orCLL03peqPqwVUdyBWj+uUVsQfXwrJr/FxXeeSUQ=","X-Received":"by 10.84.246.203 with SMTP id j11mr5955348plt.312.1505757484867;\n\tMon, 18 Sep 2017 10:58:04 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<20170918172617.GI4582@redhat.com>","References":"<CAG4ZjN=teuigpysiMSm+tE+3S4dm+WM=7n7A80gXBDFpdqfhBQ@mail.gmail.com>\n\t<20170915153954.GH4582@redhat.com>\n\t<20170918172617.GI4582@redhat.com>","From":"\"Tim Shen via gcc-patches\" <gcc-patches@gcc.gnu.org>","Reply-To":"Tim Shen <timshen@google.com>","Date":"Mon, 18 Sep 2017 10:58:04 -0700","Message-ID":"<CAG4ZjN=ioGfbwB+95ns=MaOAP0++UP9ZLwzex1fGcU7+DSxWMQ@mail.gmail.com>","Subject":"Re: [libstdc++/71500] make back reference work with icase","To":"Jonathan Wakely <jwakely@redhat.com>","Cc":"\"libstdc++\" <libstdc++@gcc.gnu.org>,\n\tgcc-patches <gcc-patches@gcc.gnu.org>","Content-Type":"text/plain; charset=\"UTF-8\""}},{"id":1770569,"web_url":"http://patchwork.ozlabs.org/comment/1770569/","msgid":"<20170918230148.GK4582@redhat.com>","list_archive_url":null,"date":"2017-09-18T23:01:48","subject":"Re: [libstdc++/71500] make back reference work with icase","submitter":{"id":48004,"url":"http://patchwork.ozlabs.org/api/people/48004/","name":"Jonathan Wakely","email":"jwakely@redhat.com"},"content":"On 18/09/17 10:58 -0700, Tim Shen via libstdc++ wrote:\n>On Mon, Sep 18, 2017 at 10:26 AM, Jonathan Wakely <jwakely@redhat.com> wrote:\n>>> We need to rewrite this to check the lengths are equal first, and then\n>>> call the 3-argument version of std::equal.\n>>>\n>>> Alternatively, we could move the implementation of the C++14\n>>> std::equal overloads to __equal and make that available for C++11.\n>>> I'll try that.\n>>\n>>\n>> Here's a proof of concept patch for that. It's a bit ugly.\n>\n>Instead of having iterator tags in the interface, we can probe the\n>random-access-ness inside __equal4/__equal4_p, can't we? It's similar\n>to the existing \"if (_RAIters()) { ... }\".\n>\n>I'd expect the patches to be renaming the current implementations and\n>adding wrappers, instead of adding new implementations.\n\nWell I decided to split the existing functions up and use tag\ndispatching, which is conceptually cleaner anyway. But as the\nRandomAccessIterator version doesn't need any operations that aren't\nvalid for other categories, it's not strictly necessary. The tag\ndispatching version should generate slightly smaller code for\nunoptimized builds, but that's not very important.\n\nHere's the patch doing it as you suggest. We can't call the new\nfunctions __equal because t hat name is already taken by a helper\nstruct, hence __equal4.\n\nDo you prefer this version?\ndiff --git a/libstdc++-v3/include/bits/regex_executor.tcc b/libstdc++-v3/include/bits/regex_executor.tcc\nindex f6149fecf9d..2ceba35e7b8 100644\n--- a/libstdc++-v3/include/bits/regex_executor.tcc\n+++ b/libstdc++-v3/include/bits/regex_executor.tcc\n@@ -366,17 +366,17 @@ namespace __detail\n \t       _BiIter __actual_end)\n       {\n \tif (!_M_icase)\n-\t  return std::equal(__expected_begin, __expected_end,\n-\t\t\t    __actual_begin, __actual_end);\n+\t  return std::__equal4(__expected_begin, __expected_end,\n+\t\t\t       __actual_begin, __actual_end);\n \ttypedef std::ctype<_CharT> __ctype_type;\n \tconst auto& __fctyp = use_facet<__ctype_type>(_M_traits.getloc());\n-\treturn std::equal(__expected_begin, __expected_end,\n-\t\t\t  __actual_begin, __actual_end,\n-\t\t\t  [this, &__fctyp](_CharT __lhs, _CharT __rhs)\n-\t\t\t  {\n-\t\t\t    return __fctyp.tolower(__lhs)\n-\t\t\t\t== __fctyp.tolower(__rhs);\n-\t\t\t  });\n+\treturn std::__equal4(__expected_begin, __expected_end,\n+\t\t\t     __actual_begin, __actual_end,\n+\t\t\t     [this, &__fctyp](_CharT __lhs, _CharT __rhs)\n+\t\t\t     {\n+\t\t\t       return __fctyp.tolower(__lhs)\n+\t\t\t\t == __fctyp.tolower(__rhs);\n+\t\t\t     });\n       }\n \n       bool _M_icase;\ndiff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h\nindex f68ecb22b82..ff5e94d9ae8 100644\n--- a/libstdc++-v3/include/bits/stl_algobase.h\n+++ b/libstdc++-v3/include/bits/stl_algobase.h\n@@ -1082,6 +1082,58 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO\n       return true;\n     }\n \n+#if __cplusplus >= 201103L\n+  template<typename _II1, typename _II2>\n+    inline bool\n+    __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2)\n+    {\n+      using _RATag = random_access_iterator_tag;\n+      using _Cat1 = typename iterator_traits<_II1>::iterator_category;\n+      using _Cat2 = typename iterator_traits<_II2>::iterator_category;\n+      using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;\n+      if (_RAIters())\n+\t{\n+\t  auto __d1 = std::distance(__first1, __last1);\n+\t  auto __d2 = std::distance(__first2, __last2);\n+\t  if (__d1 != __d2)\n+\t    return false;\n+\t  return _GLIBCXX_STD_A::equal(__first1, __last1, __first2);\n+\t}\n+\n+      for (; __first1 != __last1 && __first2 != __last2;\n+\t  ++__first1, (void)++__first2)\n+\tif (!(*__first1 == *__first2))\n+\t  return false;\n+      return __first1 == __last1 && __first2 == __last2;\n+    }\n+\n+  template<typename _II1, typename _II2, typename _BinaryPredicate>\n+    inline bool\n+    __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2,\n+\t     _BinaryPredicate __binary_pred)\n+    {\n+      using _RATag = random_access_iterator_tag;\n+      using _Cat1 = typename iterator_traits<_II1>::iterator_category;\n+      using _Cat2 = typename iterator_traits<_II2>::iterator_category;\n+      using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;\n+      if (_RAIters())\n+\t{\n+\t  auto __d1 = std::distance(__first1, __last1);\n+\t  auto __d2 = std::distance(__first2, __last2);\n+\t  if (__d1 != __d2)\n+\t    return false;\n+\t  return _GLIBCXX_STD_A::equal(__first1, __last1, __first2,\n+\t\t\t\t       __binary_pred);\n+\t}\n+\n+      for (; __first1 != __last1 && __first2 != __last2;\n+\t  ++__first1, (void)++__first2)\n+\tif (!bool(__binary_pred(*__first1, *__first2)))\n+\t  return false;\n+      return __first1 == __last1 && __first2 == __last2;\n+    }\n+#endif // C++11\n+\n #if __cplusplus > 201103L\n \n #define __cpp_lib_robust_nonmodifying_seq_ops 201304\n@@ -1112,24 +1164,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO\n       __glibcxx_requires_valid_range(__first1, __last1);\n       __glibcxx_requires_valid_range(__first2, __last2);\n \n-      using _RATag = random_access_iterator_tag;\n-      using _Cat1 = typename iterator_traits<_II1>::iterator_category;\n-      using _Cat2 = typename iterator_traits<_II2>::iterator_category;\n-      using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;\n-      if (_RAIters())\n-\t{\n-\t  auto __d1 = std::distance(__first1, __last1);\n-\t  auto __d2 = std::distance(__first2, __last2);\n-\t  if (__d1 != __d2)\n-\t    return false;\n-\t  return _GLIBCXX_STD_A::equal(__first1, __last1, __first2);\n-\t}\n-\n-      for (; __first1 != __last1 && __first2 != __last2;\n-\t  ++__first1, (void)++__first2)\n-\tif (!(*__first1 == *__first2))\n-\t  return false;\n-      return __first1 == __last1 && __first2 == __last2;\n+      return _GLIBCXX_STD_A::__equal4(__first1, __last1, __first2, __last2);\n     }\n \n   /**\n@@ -1159,27 +1194,10 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO\n       __glibcxx_requires_valid_range(__first1, __last1);\n       __glibcxx_requires_valid_range(__first2, __last2);\n \n-      using _RATag = random_access_iterator_tag;\n-      using _Cat1 = typename iterator_traits<_IIter1>::iterator_category;\n-      using _Cat2 = typename iterator_traits<_IIter2>::iterator_category;\n-      using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;\n-      if (_RAIters())\n-\t{\n-\t  auto __d1 = std::distance(__first1, __last1);\n-\t  auto __d2 = std::distance(__first2, __last2);\n-\t  if (__d1 != __d2)\n-\t    return false;\n-\t  return _GLIBCXX_STD_A::equal(__first1, __last1, __first2,\n-\t\t\t\t       __binary_pred);\n-\t}\n-\n-      for (; __first1 != __last1 && __first2 != __last2;\n-\t  ++__first1, (void)++__first2)\n-\tif (!bool(__binary_pred(*__first1, *__first2)))\n-\t  return false;\n-      return __first1 == __last1 && __first2 == __last2;\n+      return _GLIBCXX_STD_A::__equal4(__first1, __last1, __first2, __last2,\n+\t\t\t\t      __binary_pred);\n     }\n-#endif\n+#endif // C++14\n \n   /**\n    *  @brief Performs @b dictionary comparison on ranges.","headers":{"Return-Path":"<gcc-patches-return-462448-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462448-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"PoL9Uxlf\"; dkim-atps=neutral","sourceware.org; auth=none","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=jwakely@redhat.com"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xx1jS3QD8z9s7M\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 09:02:02 +1000 (AEST)","(qmail 14551 invoked by alias); 18 Sep 2017 23:01:53 -0000","(qmail 14140 invoked by uid 89); 18 Sep 2017 23:01:52 -0000","from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tMon, 18 Sep 2017 23:01:50 +0000","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com\n\t[10.5.11.11])\t(using TLSv1.2 with cipher AECDH-AES256-SHA\n\t(256/256 bits))\t(No client certificate requested)\tby\n\tmx1.redhat.com (Postfix) with ESMTPS id AB7402027C;\n\tMon, 18 Sep 2017 23:01:49 +0000 (UTC)","from localhost (unknown [10.33.36.48])\tby smtp.corp.redhat.com\n\t(Postfix) with ESMTP id 5C83760466;\n\tMon, 18 Sep 2017 23:01:49 +0000 (UTC)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; q=dns; s=default; b=drDzTM5QgocxO6q8J\n\t0YQein2x99aqtxySb6Zp/gbZLCsrdWkOBLLwW6sDydI2loSa1LfvVjuVPXQO/Ndj\n\tJDpYZq0sC/xONK96T5lzsR+lsM03rsmp4vwqkAst2NPJ5jon7S/hBThoWmmjlJV9\n\txH05O8mqqNrfkxQi81FbAeFg8c=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; s=default; bh=HgyPUiqD5iso9b4Nc/9+W4r\n\tsS5I=; b=PoL9Uxlf8JlMRyMrx8JNP9muqS47ZtgcntubH121m0deIg3P2KP4ja0\n\tZzhoWi8GQFUSStQCwvHPR1a6UNM2rzPITr7otSPdPy4Rs3D+N8npzjCXV2Dv0z5o\n\tezSF5+tE22DGSOAuKw8eJrgUVlA6Vjufa4DgGqxkwHvm6AQNt3/g=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD,\n\tSPF_HELO_PASS autolearn=ham version=3.3.2 spammy=","X-Spam-User":"qpsmtpd, 2 recipients","X-HELO":"mx1.redhat.com","DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com AB7402027C","Date":"Tue, 19 Sep 2017 00:01:48 +0100","From":"Jonathan Wakely <jwakely@redhat.com>","To":"Tim Shen <timshen@google.com>","Cc":"libstdc++ <libstdc++@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>","Subject":"Re: [libstdc++/71500] make back reference work with icase","Message-ID":"<20170918230148.GK4582@redhat.com>","References":"<CAG4ZjN=teuigpysiMSm+tE+3S4dm+WM=7n7A80gXBDFpdqfhBQ@mail.gmail.com>\n\t<20170915153954.GH4582@redhat.com>\n\t<20170918172617.GI4582@redhat.com>\n\t<CAG4ZjN=ioGfbwB+95ns=MaOAP0++UP9ZLwzex1fGcU7+DSxWMQ@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"multipart/mixed; boundary=\"UFMLoheMaWcIEZAi\"","Content-Disposition":"inline","In-Reply-To":"<CAG4ZjN=ioGfbwB+95ns=MaOAP0++UP9ZLwzex1fGcU7+DSxWMQ@mail.gmail.com>","X-Clacks-Overhead":"GNU Terry Pratchett","User-Agent":"Mutt/1.8.3 (2017-05-23)"}},{"id":1770588,"web_url":"http://patchwork.ozlabs.org/comment/1770588/","msgid":"<CAG4ZjNkcGpcgQfp9JcTYyJiAiWupbYUdE-G=tCeWmBzesTfFqg@mail.gmail.com>","list_archive_url":null,"date":"2017-09-18T23:54:38","subject":"Re: [libstdc++/71500] make back reference work with icase","submitter":{"id":70597,"url":"http://patchwork.ozlabs.org/api/people/70597/","name":"Li, Pan2 via Gcc-patches","email":"gcc-patches@gcc.gnu.org"},"content":"On Mon, Sep 18, 2017 at 4:01 PM, Jonathan Wakely <jwakely@redhat.com> wrote:\n> On 18/09/17 10:58 -0700, Tim Shen via libstdc++ wrote:\n>>\n>> On Mon, Sep 18, 2017 at 10:26 AM, Jonathan Wakely <jwakely@redhat.com>\n>> wrote:\n>>>>\n>>>> We need to rewrite this to check the lengths are equal first, and then\n>>>> call the 3-argument version of std::equal.\n>>>>\n>>>> Alternatively, we could move the implementation of the C++14\n>>>> std::equal overloads to __equal and make that available for C++11.\n>>>> I'll try that.\n>>>\n>>>\n>>>\n>>> Here's a proof of concept patch for that. It's a bit ugly.\n>>\n>>\n>> Instead of having iterator tags in the interface, we can probe the\n>> random-access-ness inside __equal4/__equal4_p, can't we? It's similar\n>> to the existing \"if (_RAIters()) { ... }\".\n>>\n>> I'd expect the patches to be renaming the current implementations and\n>> adding wrappers, instead of adding new implementations.\n>\n>\n> Well I decided to split the existing functions up and use tag\n> dispatching, which is conceptually cleaner anyway. But as the\n> RandomAccessIterator version doesn't need any operations that aren't\n> valid for other categories, it's not strictly necessary. The tag\n> dispatching version should generate slightly smaller code for\n> unoptimized builds, but that's not very important.\n\nUnoptimized builds don't inline small functions, therefore the first\npatch generate two weak symbols, instead of one by the second patch.\nIt's unclear to me how would number of symbols penalize the\nperformance/binary size.\n\n>\n> Here's the patch doing it as you suggest. We can't call the new\n> functions __equal because t hat name is already taken by a helper\n> struct, hence __equal4.\n>\n> Do you prefer this version?\n\nYes, I prefer this version for readability reasons:\n1) subjectively, less scattered code; and\n2) ideally I want `if constexpr (...)`), the if version is closer.\n\nI agree that it's not a big difference. I just wanted to point out the\nsmall difference. I'm fine with either version.\n\nThanks for the prototyping!","headers":{"Return-Path":"<gcc-patches-return-462451-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462451-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"x4Bs5csP\"; dkim-atps=neutral","sourceware.org; auth=none"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xx2tN00J1z9s5L\n\tfor <incoming@patchwork.ozlabs.org>;\n\tTue, 19 Sep 2017 09:54:49 +1000 (AEST)","(qmail 91781 invoked by alias); 18 Sep 2017 23:54:43 -0000","(qmail 91760 invoked by uid 89); 18 Sep 2017 23:54:42 -0000","from mail-pf0-f176.google.com (HELO mail-pf0-f176.google.com)\n\t(209.85.192.176) by sourceware.org\n\t(qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tMon, 18 Sep 2017 23:54:41 +0000","by mail-pf0-f176.google.com with SMTP id r68so24620pfj.3 for\n\t<gcc-patches@gcc.gnu.org>; Mon, 18 Sep 2017 16:54:40 -0700 (PDT)","by 10.100.178.164 with HTTP; Mon, 18 Sep 2017 16:54:38 -0700 (PDT)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:in-reply-to:references:from:reply-to:date\n\t:message-id:subject:to:cc:content-type; q=dns; s=default; b=X3Jw\n\t0s01Jh2QK1jJXzDUOESRJ/D9BO1eq/VNI51ipBNRYWHOAS1QfA7iR2jN7haDcZGy\n\tWOpPSkSUPa8gP8TgpaCA2omyBR/xN2xAfB784+v/k6JFcjXGOtH99LPaDQ+Mt9BH\n\tfRPPQC8oIrQb0b8pX5JqEjrqj/RgbkO4xU1n9xE=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender\n\t:mime-version:in-reply-to:references:from:reply-to:date\n\t:message-id:subject:to:cc:content-type; s=default; bh=cFK8CNCE9U\n\tQdNwc94FPbEFmsP4I=; b=x4Bs5csPGsDZHqXiUJBMXB8QAyCYYE0CEvlgOd2L3o\n\tknlLv81bKSE3BUw08nO1G0NqBUWAnvuRMCgAvm7xQOtCgpH+JEMjWkt854BQUKH5\n\thAeqbphLgtT9hlPJae6mvWO1dBjrZ4pCZNKh0rsIQfljhh8g7+iaXfg5PZ8dZCQS\n\ts=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-1.9 required=5.0 tests=AWL, BAYES_00,\n\tRCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD,\n\tSPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2116,\n\tscattered","X-HELO":"mail-pf0-f176.google.com","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net;\n\ts=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=Ac8xHrUadrjiumFVfMqwxECmrSniir9Ic8mlMbGlWKM=;\n\tb=W4qAdOovnaOMDsoecjv3bdX5Jxp1HBX6LHY8fVpNd29A+YwPAXsx9lsyef0QhxuGHe\n\t4cS6eLgmPrNlzClRlK0W/SyFgE+YXH7uc7XkT9e9xBhRkjlKxhqAXP7Jb0V+bMlj7rCB\n\tm5vfGATidajtiRwojjSiROZhZNl7MBnAvo6Og8NhVtGXXWkzBuQBT4FCs6fTSA29uBGr\n\t4J7tAegog7n2VgQClz04GrWba/cSEUxPqL6fnjJFgMEJ6gH8NHX3YNHX+790s0ONLwnK\n\t6Oi5SHDpCYEPZ7bokBL3HnwPYMWXbVMnDypPEMDgAvECQhIoFgVgGuHkocyZkVN+3nY0\n\tASoA==","X-Gm-Message-State":"AHPjjUhkEiMjj1fbjNlNkN/c+hjz+KBu2itG8ZK/rCcufphK27pPfxpv\tpK5twHLO+UoYfKzvGIbuHzTct/di8z2ePqUz6B7zLQ==","X-Google-Smtp-Source":"AOwi7QD1ki5Ug8rdDHqNIPytU35fQHEszjA/xsHZqHLNJuBcdaspwvYLN3LgXxsbwJ7t1nTGqxUxmOqiVrB4jCv3vjE=","X-Received":"by 10.84.130.67 with SMTP id 61mr254912plc.131.1505778879140;\n\tMon, 18 Sep 2017 16:54:39 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<20170918230148.GK4582@redhat.com>","References":"<CAG4ZjN=teuigpysiMSm+tE+3S4dm+WM=7n7A80gXBDFpdqfhBQ@mail.gmail.com>\n\t<20170915153954.GH4582@redhat.com>\n\t<20170918172617.GI4582@redhat.com>\n\t<CAG4ZjN=ioGfbwB+95ns=MaOAP0++UP9ZLwzex1fGcU7+DSxWMQ@mail.gmail.com>\n\t<20170918230148.GK4582@redhat.com>","From":"\"Tim Shen via gcc-patches\" <gcc-patches@gcc.gnu.org>","Reply-To":"Tim Shen <timshen@google.com>","Date":"Mon, 18 Sep 2017 16:54:38 -0700","Message-ID":"<CAG4ZjNkcGpcgQfp9JcTYyJiAiWupbYUdE-G=tCeWmBzesTfFqg@mail.gmail.com>","Subject":"Re: [libstdc++/71500] make back reference work with icase","To":"Jonathan Wakely <jwakely@redhat.com>","Cc":"\"libstdc++\" <libstdc++@gcc.gnu.org>,\n\tgcc-patches <gcc-patches@gcc.gnu.org>","Content-Type":"text/plain; charset=\"UTF-8\""}},{"id":1771091,"web_url":"http://patchwork.ozlabs.org/comment/1771091/","msgid":"<20170919143858.GL4582@redhat.com>","list_archive_url":null,"date":"2017-09-19T14:38:58","subject":"Re: [libstdc++/71500] make back reference work with icase","submitter":{"id":48004,"url":"http://patchwork.ozlabs.org/api/people/48004/","name":"Jonathan Wakely","email":"jwakely@redhat.com"},"content":"On 18/09/17 16:54 -0700, Tim Shen wrote:\n>On Mon, Sep 18, 2017 at 4:01 PM, Jonathan Wakely <jwakely@redhat.com> wrote:\n>> On 18/09/17 10:58 -0700, Tim Shen via libstdc++ wrote:\n>>>\n>>> On Mon, Sep 18, 2017 at 10:26 AM, Jonathan Wakely <jwakely@redhat.com>\n>>> wrote:\n>>>>>\n>>>>> We need to rewrite this to check the lengths are equal first, and then\n>>>>> call the 3-argument version of std::equal.\n>>>>>\n>>>>> Alternatively, we could move the implementation of the C++14\n>>>>> std::equal overloads to __equal and make that available for C++11.\n>>>>> I'll try that.\n>>>>\n>>>>\n>>>>\n>>>> Here's a proof of concept patch for that. It's a bit ugly.\n>>>\n>>>\n>>> Instead of having iterator tags in the interface, we can probe the\n>>> random-access-ness inside __equal4/__equal4_p, can't we? It's similar\n>>> to the existing \"if (_RAIters()) { ... }\".\n>>>\n>>> I'd expect the patches to be renaming the current implementations and\n>>> adding wrappers, instead of adding new implementations.\n>>\n>>\n>> Well I decided to split the existing functions up and use tag\n>> dispatching, which is conceptually cleaner anyway. But as the\n>> RandomAccessIterator version doesn't need any operations that aren't\n>> valid for other categories, it's not strictly necessary. The tag\n>> dispatching version should generate slightly smaller code for\n>> unoptimized builds, but that's not very important.\n>\n>Unoptimized builds don't inline small functions, therefore the first\n>patch generate two weak symbols, instead of one by the second patch.\n\nTwo small functions that only do the necessary work, rather than one\nlarge function that has a branch for RAIters even when it can never be\ntaken.\n\n>It's unclear to me how would number of symbols penalize the\n>performance/binary size.\n\nPeople who care about performance or binary size should be optimizing,\nand in that case the RAIters branch will be known at compile-time and\nthe dead code should get removed, and the wrapper functions inlined.\n\n>> Here's the patch doing it as you suggest. We can't call the new\n>> functions __equal because t hat name is already taken by a helper\n>> struct, hence __equal4.\n>>\n>> Do you prefer this version?\n>\n>Yes, I prefer this version for readability reasons:\n>1) subjectively, less scattered code; and\n>2) ideally I want `if constexpr (...)`), the if version is closer.\n\nYes, we could add _GLIBCXX17_CONSTEXPR there, but I'm not sure it's\nworth doing.\n\n3) The calls to __equal4 in _Backref_matcher are simpler.\n\n>I agree that it's not a big difference. I just wanted to point out the\n>small difference. I'm fine with either version.\n\nI'll commit the second version.\n\n>Thanks for the prototyping!\n>\n>\n>-- \n>Regards,\n>Tim Shen","headers":{"Return-Path":"<gcc-patches-return-462495-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462495-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"cWJG/k88\"; dkim-atps=neutral","sourceware.org; auth=none","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx09.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=jwakely@redhat.com"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxQVk2h70z9s7h\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 00:39:09 +1000 (AEST)","(qmail 88304 invoked by alias); 19 Sep 2017 14:39:02 -0000","(qmail 88286 invoked by uid 89); 19 Sep 2017 14:39:01 -0000","from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tTue, 19 Sep 2017 14:39:00 +0000","from smtp.corp.redhat.com\n\t(int-mx04.intmail.prod.int.phx2.redhat.com\n\t[10.5.11.14])\t(using TLSv1.2 with cipher AECDH-AES256-SHA\n\t(256/256 bits))\t(No client certificate requested)\tby\n\tmx1.redhat.com (Postfix) with ESMTPS id 68D277247B;\n\tTue, 19 Sep 2017 14:38:59 +0000 (UTC)","from localhost (unknown [10.33.36.48])\tby smtp.corp.redhat.com\n\t(Postfix) with ESMTP id 1A2F45D97D;\n\tTue, 19 Sep 2017 14:38:58 +0000 (UTC)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; q=dns; s=default; b=So6SgEdjFvBENLHai\n\t1SYIA7BHa8XdRN4VN+OtKwkLi6CkX7emJRMqK2IbrDlBj07htPUHM1Jj4IrJs1Bt\n\tOFEDSWy8XDVnKBzZLElEjQJhCb6Y/jfoaZzdjWVGeTJJYqdC6HXWA4cTpx3J08dq\n\tBUtzIKP6m4Cv3SghPtIhY+Zw+M=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; s=default; bh=OR+/RfGD7xodMCVPMwoQOCr\n\tDHwo=; b=cWJG/k88KeaiNf6OmnRAS7WdO64wUWMQ5Del8VWxChLp+fd7DsxVUpQ\n\tNCc4hZcQq2djsCqJd0zA4nGGDJ/G3QYA1ZO0qNlGTBbf1IYUlKz9/2CVBv8GOVZF\n\tLLU39hjoYbVqdNEakAmS0sSHokauYU/TrnugEf9SYfgIWWBseSsY=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-1.9 required=5.0 tests=BAYES_00,\n\tRP_MATCHES_RCVD,\n\tSPF_HELO_PASS autolearn=ham version=3.3.2 spammy=","X-Spam-User":"qpsmtpd, 2 recipients","X-HELO":"mx1.redhat.com","DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 68D277247B","Date":"Tue, 19 Sep 2017 15:38:58 +0100","From":"Jonathan Wakely <jwakely@redhat.com>","To":"Tim Shen <timshen@google.com>","Cc":"libstdc++ <libstdc++@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>","Subject":"Re: [libstdc++/71500] make back reference work with icase","Message-ID":"<20170919143858.GL4582@redhat.com>","References":"<CAG4ZjN=teuigpysiMSm+tE+3S4dm+WM=7n7A80gXBDFpdqfhBQ@mail.gmail.com>\n\t<20170915153954.GH4582@redhat.com>\n\t<20170918172617.GI4582@redhat.com>\n\t<CAG4ZjN=ioGfbwB+95ns=MaOAP0++UP9ZLwzex1fGcU7+DSxWMQ@mail.gmail.com>\n\t<20170918230148.GK4582@redhat.com>\n\t<CAG4ZjNkcGpcgQfp9JcTYyJiAiWupbYUdE-G=tCeWmBzesTfFqg@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii; format=flowed","Content-Disposition":"inline","In-Reply-To":"<CAG4ZjNkcGpcgQfp9JcTYyJiAiWupbYUdE-G=tCeWmBzesTfFqg@mail.gmail.com>","X-Clacks-Overhead":"GNU Terry Pratchett","User-Agent":"Mutt/1.8.3 (2017-05-23)"}},{"id":1771094,"web_url":"http://patchwork.ozlabs.org/comment/1771094/","msgid":"<20170919144121.GM4582@redhat.com>","list_archive_url":null,"date":"2017-09-19T14:41:21","subject":"Re: [libstdc++/71500] make back reference work with icase","submitter":{"id":48004,"url":"http://patchwork.ozlabs.org/api/people/48004/","name":"Jonathan Wakely","email":"jwakely@redhat.com"},"content":"The failures that need to be fixed can be seen at \nhttps://gcc.gnu.org/ml/gcc-testresults/2017-09/msg01633.html","headers":{"Return-Path":"<gcc-patches-return-462496-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462496-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"vzvhorZB\"; dkim-atps=neutral","sourceware.org; auth=none","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx05.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=jwakely@redhat.com"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxQYc0J2bz9s7m\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 00:41:39 +1000 (AEST)","(qmail 25784 invoked by alias); 19 Sep 2017 14:41:25 -0000","(qmail 25764 invoked by uid 89); 19 Sep 2017 14:41:24 -0000","from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tTue, 19 Sep 2017 14:41:23 +0000","from smtp.corp.redhat.com\n\t(int-mx01.intmail.prod.int.phx2.redhat.com\n\t[10.5.11.11])\t(using TLSv1.2 with cipher AECDH-AES256-SHA\n\t(256/256 bits))\t(No client certificate requested)\tby\n\tmx1.redhat.com (Postfix) with ESMTPS id 3ED1D90901;\n\tTue, 19 Sep 2017 14:41:22 +0000 (UTC)","from localhost (unknown [10.33.36.48])\tby smtp.corp.redhat.com\n\t(Postfix) with ESMTP id E3FED61342;\n\tTue, 19 Sep 2017 14:41:21 +0000 (UTC)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; q=dns; s=default; b=wedcvh+DYbwfq+fzr\n\tJe8IALwGZUQWFeGq15S6icjZJqyxzl7hyXS/m+9FCgOBFLX1tbNFltwyL9NyM2nn\n\tSD80qSV4CnKm7isnTPIdwnuKaCjypDqErCi2vDqO9AwupvZnrpCzcY5RLIEu/fBw\n\tCzt+xD4s6OzoJccfEfgib+t4gg=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; s=default; bh=xT1ErfHoahadsK2lbBwTk0w\n\t4BXQ=; b=vzvhorZB+H6mhlZg4JyZblbyhhIPkyhg8OOJLz9yW3AUyKgzSMQGVQ3\n\t6QWAG7onhW34sbD+ZvNozyeuVLSYnsZH54OC2vdQnxnWyZvcKqG+cd0LkvoVLk1W\n\t6JkK6+80/dOs5aCov37zwfbsfkQjo3BiuxtajvxST0+gFShpO0jo=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-0.9 required=5.0 tests=BAYES_00,\n\tKAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD,\n\tSPF_HELO_PASS autolearn=no version=3.3.2\n\tspammy=Hx-languages-length:170","X-Spam-User":"qpsmtpd, 2 recipients","X-HELO":"mx1.redhat.com","DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 3ED1D90901","Date":"Tue, 19 Sep 2017 15:41:21 +0100","From":"Jonathan Wakely <jwakely@redhat.com>","To":"Tim Shen <timshen@google.com>","Cc":"libstdc++ <libstdc++@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>","Subject":"Re: [libstdc++/71500] make back reference work with icase","Message-ID":"<20170919144121.GM4582@redhat.com>","References":"<CAG4ZjN=teuigpysiMSm+tE+3S4dm+WM=7n7A80gXBDFpdqfhBQ@mail.gmail.com>\n\t<20170915153954.GH4582@redhat.com>\n\t<20170918172617.GI4582@redhat.com>\n\t<CAG4ZjN=ioGfbwB+95ns=MaOAP0++UP9ZLwzex1fGcU7+DSxWMQ@mail.gmail.com>\n\t<20170918230148.GK4582@redhat.com>\n\t<CAG4ZjNkcGpcgQfp9JcTYyJiAiWupbYUdE-G=tCeWmBzesTfFqg@mail.gmail.com>\n\t<20170919143858.GL4582@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii; format=flowed","Content-Disposition":"inline","In-Reply-To":"<20170919143858.GL4582@redhat.com>","X-Clacks-Overhead":"GNU Terry Pratchett","User-Agent":"Mutt/1.8.3 (2017-05-23)"}},{"id":1771215,"web_url":"http://patchwork.ozlabs.org/comment/1771215/","msgid":"<20170919170729.GN4582@redhat.com>","list_archive_url":null,"date":"2017-09-19T17:07:29","subject":"Re: [libstdc++/71500] make back reference work with icase","submitter":{"id":48004,"url":"http://patchwork.ozlabs.org/api/people/48004/","name":"Jonathan Wakely","email":"jwakely@redhat.com"},"content":"On 19/09/17 15:38 +0100, Jonathan Wakely wrote:\n>On 18/09/17 16:54 -0700, Tim Shen wrote:\n>>On Mon, Sep 18, 2017 at 4:01 PM, Jonathan Wakely <jwakely@redhat.com> wrote:\n>>>On 18/09/17 10:58 -0700, Tim Shen via libstdc++ wrote:\n>>>>\n>>>>On Mon, Sep 18, 2017 at 10:26 AM, Jonathan Wakely <jwakely@redhat.com>\n>>>>wrote:\n>>>>>>\n>>>>>>We need to rewrite this to check the lengths are equal first, and then\n>>>>>>call the 3-argument version of std::equal.\n>>>>>>\n>>>>>>Alternatively, we could move the implementation of the C++14\n>>>>>>std::equal overloads to __equal and make that available for C++11.\n>>>>>>I'll try that.\n>>>>>\n>>>>>\n>>>>>\n>>>>>Here's a proof of concept patch for that. It's a bit ugly.\n>>>>\n>>>>\n>>>>Instead of having iterator tags in the interface, we can probe the\n>>>>random-access-ness inside __equal4/__equal4_p, can't we? It's similar\n>>>>to the existing \"if (_RAIters()) { ... }\".\n>>>>\n>>>>I'd expect the patches to be renaming the current implementations and\n>>>>adding wrappers, instead of adding new implementations.\n>>>\n>>>\n>>>Well I decided to split the existing functions up and use tag\n>>>dispatching, which is conceptually cleaner anyway. But as the\n>>>RandomAccessIterator version doesn't need any operations that aren't\n>>>valid for other categories, it's not strictly necessary. The tag\n>>>dispatching version should generate slightly smaller code for\n>>>unoptimized builds, but that's not very important.\n>>\n>>Unoptimized builds don't inline small functions, therefore the first\n>>patch generate two weak symbols, instead of one by the second patch.\n>\n>Two small functions that only do the necessary work, rather than one\n>large function that has a branch for RAIters even when it can never be\n>taken.\n>\n>>It's unclear to me how would number of symbols penalize the\n>>performance/binary size.\n>\n>People who care about performance or binary size should be optimizing,\n>and in that case the RAIters branch will be known at compile-time and\n>the dead code should get removed, and the wrapper functions inlined.\n>\n>>>Here's the patch doing it as you suggest. We can't call the new\n>>>functions __equal because t hat name is already taken by a helper\n>>>struct, hence __equal4.\n>>>\n>>>Do you prefer this version?\n>>\n>>Yes, I prefer this version for readability reasons:\n>>1) subjectively, less scattered code; and\n>>2) ideally I want `if constexpr (...)`), the if version is closer.\n>\n>Yes, we could add _GLIBCXX17_CONSTEXPR there, but I'm not sure it's\n>worth doing.\n>\n>3) The calls to __equal4 in _Backref_matcher are simpler.\n>\n>>I agree that it's not a big difference. I just wanted to point out the\n>>small difference. I'm fine with either version.\n>\n>I'll commit the second version.\n\nHere's what I've committed, with a minimal test to catch this\nhappening in future.\n\nI'll re-run the full set of test variations.\ncommit 371c5de025c0fc95420d96bf96f3da84e3725c9d\nAuthor: Jonathan Wakely <jwakely@redhat.com>\nDate:   Tue Sep 19 17:36:52 2017 +0100\n\n    PR libstdc++/71500 restore C++11 compatibility in <regex>\n    \n            PR libstdc++/71500\n            * include/bits/regex_executor.tcc\n            (_Backref_matcher<BidIt, regex_traits<C>>::_M_apply): Use\n            std::__equal4 instead of C++14 4-iterator overloads of std::equal.\n            * include/bits/stl_algobase.h (__equal4): New functions implementing\n            4-iterator overloads of std::equal for use in C++11.\n            (equal(It1, It1, It2, It2), equal(It1, It1, It2, It2, BinaryPred)):\n            Move function bodies to new __equal4 functions.\n            * testsuite/28_regex/simple_c++11.cc: New.\n\ndiff --git a/libstdc++-v3/include/bits/regex_executor.tcc b/libstdc++-v3/include/bits/regex_executor.tcc\nindex f6149fecf9d..2ceba35e7b8 100644\n--- a/libstdc++-v3/include/bits/regex_executor.tcc\n+++ b/libstdc++-v3/include/bits/regex_executor.tcc\n@@ -366,17 +366,17 @@ namespace __detail\n \t       _BiIter __actual_end)\n       {\n \tif (!_M_icase)\n-\t  return std::equal(__expected_begin, __expected_end,\n-\t\t\t    __actual_begin, __actual_end);\n+\t  return std::__equal4(__expected_begin, __expected_end,\n+\t\t\t       __actual_begin, __actual_end);\n \ttypedef std::ctype<_CharT> __ctype_type;\n \tconst auto& __fctyp = use_facet<__ctype_type>(_M_traits.getloc());\n-\treturn std::equal(__expected_begin, __expected_end,\n-\t\t\t  __actual_begin, __actual_end,\n-\t\t\t  [this, &__fctyp](_CharT __lhs, _CharT __rhs)\n-\t\t\t  {\n-\t\t\t    return __fctyp.tolower(__lhs)\n-\t\t\t\t== __fctyp.tolower(__rhs);\n-\t\t\t  });\n+\treturn std::__equal4(__expected_begin, __expected_end,\n+\t\t\t     __actual_begin, __actual_end,\n+\t\t\t     [this, &__fctyp](_CharT __lhs, _CharT __rhs)\n+\t\t\t     {\n+\t\t\t       return __fctyp.tolower(__lhs)\n+\t\t\t\t == __fctyp.tolower(__rhs);\n+\t\t\t     });\n       }\n \n       bool _M_icase;\ndiff --git a/libstdc++-v3/include/bits/stl_algobase.h b/libstdc++-v3/include/bits/stl_algobase.h\nindex f68ecb22b82..a80934c4faa 100644\n--- a/libstdc++-v3/include/bits/stl_algobase.h\n+++ b/libstdc++-v3/include/bits/stl_algobase.h\n@@ -1082,6 +1082,60 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO\n       return true;\n     }\n \n+#if __cplusplus >= 201103L\n+  // 4-iterator version of std::equal<It1, It2> for use in C++11.\n+  template<typename _II1, typename _II2>\n+    inline bool\n+    __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2)\n+    {\n+      using _RATag = random_access_iterator_tag;\n+      using _Cat1 = typename iterator_traits<_II1>::iterator_category;\n+      using _Cat2 = typename iterator_traits<_II2>::iterator_category;\n+      using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;\n+      if (_RAIters())\n+\t{\n+\t  auto __d1 = std::distance(__first1, __last1);\n+\t  auto __d2 = std::distance(__first2, __last2);\n+\t  if (__d1 != __d2)\n+\t    return false;\n+\t  return _GLIBCXX_STD_A::equal(__first1, __last1, __first2);\n+\t}\n+\n+      for (; __first1 != __last1 && __first2 != __last2;\n+\t  ++__first1, (void)++__first2)\n+\tif (!(*__first1 == *__first2))\n+\t  return false;\n+      return __first1 == __last1 && __first2 == __last2;\n+    }\n+\n+  // 4-iterator version of std::equal<It1, It2, BinaryPred> for use in C++11.\n+  template<typename _II1, typename _II2, typename _BinaryPredicate>\n+    inline bool\n+    __equal4(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2,\n+\t     _BinaryPredicate __binary_pred)\n+    {\n+      using _RATag = random_access_iterator_tag;\n+      using _Cat1 = typename iterator_traits<_II1>::iterator_category;\n+      using _Cat2 = typename iterator_traits<_II2>::iterator_category;\n+      using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;\n+      if (_RAIters())\n+\t{\n+\t  auto __d1 = std::distance(__first1, __last1);\n+\t  auto __d2 = std::distance(__first2, __last2);\n+\t  if (__d1 != __d2)\n+\t    return false;\n+\t  return _GLIBCXX_STD_A::equal(__first1, __last1, __first2,\n+\t\t\t\t       __binary_pred);\n+\t}\n+\n+      for (; __first1 != __last1 && __first2 != __last2;\n+\t  ++__first1, (void)++__first2)\n+\tif (!bool(__binary_pred(*__first1, *__first2)))\n+\t  return false;\n+      return __first1 == __last1 && __first2 == __last2;\n+    }\n+#endif // C++11\n+\n #if __cplusplus > 201103L\n \n #define __cpp_lib_robust_nonmodifying_seq_ops 201304\n@@ -1112,24 +1166,7 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO\n       __glibcxx_requires_valid_range(__first1, __last1);\n       __glibcxx_requires_valid_range(__first2, __last2);\n \n-      using _RATag = random_access_iterator_tag;\n-      using _Cat1 = typename iterator_traits<_II1>::iterator_category;\n-      using _Cat2 = typename iterator_traits<_II2>::iterator_category;\n-      using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;\n-      if (_RAIters())\n-\t{\n-\t  auto __d1 = std::distance(__first1, __last1);\n-\t  auto __d2 = std::distance(__first2, __last2);\n-\t  if (__d1 != __d2)\n-\t    return false;\n-\t  return _GLIBCXX_STD_A::equal(__first1, __last1, __first2);\n-\t}\n-\n-      for (; __first1 != __last1 && __first2 != __last2;\n-\t  ++__first1, (void)++__first2)\n-\tif (!(*__first1 == *__first2))\n-\t  return false;\n-      return __first1 == __last1 && __first2 == __last2;\n+      return _GLIBCXX_STD_A::__equal4(__first1, __last1, __first2, __last2);\n     }\n \n   /**\n@@ -1159,27 +1196,10 @@ _GLIBCXX_BEGIN_NAMESPACE_ALGO\n       __glibcxx_requires_valid_range(__first1, __last1);\n       __glibcxx_requires_valid_range(__first2, __last2);\n \n-      using _RATag = random_access_iterator_tag;\n-      using _Cat1 = typename iterator_traits<_IIter1>::iterator_category;\n-      using _Cat2 = typename iterator_traits<_IIter2>::iterator_category;\n-      using _RAIters = __and_<is_same<_Cat1, _RATag>, is_same<_Cat2, _RATag>>;\n-      if (_RAIters())\n-\t{\n-\t  auto __d1 = std::distance(__first1, __last1);\n-\t  auto __d2 = std::distance(__first2, __last2);\n-\t  if (__d1 != __d2)\n-\t    return false;\n-\t  return _GLIBCXX_STD_A::equal(__first1, __last1, __first2,\n-\t\t\t\t       __binary_pred);\n-\t}\n-\n-      for (; __first1 != __last1 && __first2 != __last2;\n-\t  ++__first1, (void)++__first2)\n-\tif (!bool(__binary_pred(*__first1, *__first2)))\n-\t  return false;\n-      return __first1 == __last1 && __first2 == __last2;\n+      return _GLIBCXX_STD_A::__equal4(__first1, __last1, __first2, __last2,\n+\t\t\t\t      __binary_pred);\n     }\n-#endif\n+#endif // C++14\n \n   /**\n    *  @brief Performs @b dictionary comparison on ranges.\ndiff --git a/libstdc++-v3/testsuite/28_regex/simple_c++11.cc b/libstdc++-v3/testsuite/28_regex/simple_c++11.cc\nnew file mode 100644\nindex 00000000000..2cfa503fc07\n--- /dev/null\n+++ b/libstdc++-v3/testsuite/28_regex/simple_c++11.cc\n@@ -0,0 +1,27 @@\n+// Copyright (C) 2017 Free Software Foundation, Inc.\n+//\n+// This file is part of the GNU ISO C++ Library.  This library is free\n+// software; you can redistribute it and/or modify it under the\n+// terms of the GNU General Public License as published by the\n+// Free Software Foundation; either version 3, or (at your option)\n+// any later version.\n+\n+// This library is distributed in the hope that it will be useful,\n+// but WITHOUT ANY WARRANTY; without even the implied warranty of\n+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+// GNU General Public License for more details.\n+\n+// You should have received a copy of the GNU General Public License along\n+// with this library; see the file COPYING3.  If not see\n+// <http://www.gnu.org/licenses/>.\n+\n+// { dg-options \"-std=gnu++11\" }\n+// { dg-do compile }\n+\n+#include <regex>\n+\n+// Ensure compilation of trivial example still works with C++11.\n+// https://gcc.gnu.org/ml/libstdc++/2017-09/msg00040.html\n+std::regex r{\"\"};\n+std::cmatch m;\n+bool b = regex_match(\"\", m, r);","headers":{"Return-Path":"<gcc-patches-return-462517-incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":["patchwork-incoming@bilbo.ozlabs.org","mailing list gcc-patches@gcc.gnu.org"],"Authentication-Results":["ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=gcc-patches-return-462517-incoming=patchwork.ozlabs.org@gcc.gnu.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org\n\theader.b=\"ML3lUsCP\"; dkim-atps=neutral","sourceware.org; auth=none","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tdmarc=none (p=none dis=none) header.from=redhat.com","ext-mx03.extmail.prod.ext.phx2.redhat.com;\n\tspf=fail smtp.mailfrom=jwakely@redhat.com"],"Received":["from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxTp66JC8z9sNw\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 03:07:42 +1000 (AEST)","(qmail 128935 invoked by alias); 19 Sep 2017 17:07:34 -0000","(qmail 128916 invoked by uid 89); 19 Sep 2017 17:07:34 -0000","from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by\n\tsourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP;\n\tTue, 19 Sep 2017 17:07:32 +0000","from smtp.corp.redhat.com\n\t(int-mx03.intmail.prod.int.phx2.redhat.com\n\t[10.5.11.13])\t(using TLSv1.2 with cipher AECDH-AES256-SHA\n\t(256/256 bits))\t(No client certificate requested)\tby\n\tmx1.redhat.com (Postfix) with ESMTPS id 24B447E431;\n\tTue, 19 Sep 2017 17:07:31 +0000 (UTC)","from localhost (unknown [10.33.36.48])\tby smtp.corp.redhat.com\n\t(Postfix) with ESMTP id AA15B6061E;\n\tTue, 19 Sep 2017 17:07:30 +0000 (UTC)"],"DomainKey-Signature":"a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; q=dns; s=default; b=kfjTwnBhPRBrAWGoA\n\tSl5jlmg+lMb13Gc2mW9TOKY8j5CwLWuoBXWue9kcmjoylGEAkA2tj4asUZuVG/3I\n\t2MXnSCZ7bR2hiPya1NmYi41QJ0OtEsilwmywCY8qYBkhb77Gxps/u6wKbeuSbiIy\n\ttvydZ9t3pn/Wzlu1pfIalxUAyc=","DKIM-Signature":"v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id\n\t:list-unsubscribe:list-archive:list-post:list-help:sender:date\n\t:from:to:cc:subject:message-id:references:mime-version\n\t:content-type:in-reply-to; s=default; bh=107MRQOGc4uJ1bsQgsmP9M0\n\tixdQ=; b=ML3lUsCPvdqDqAKRVDYYdzlWt6ELzfv1ySMIzZvX/x7DjL60A5XE/tj\n\tcagQQjd2xzzU7ZMWouomq80CcdhflZTiHsANm82IhbUQG/BokrNNFo4eKqyAVD66\n\tDoQy0u/zLveeylgF8j85FMQ1YRyrcqfnZ0Zm3tbgXzh68jDieuos=","Mailing-List":"contact gcc-patches-help@gcc.gnu.org; run by ezmlm","Precedence":"bulk","List-Id":"<gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<mailto:gcc-patches-unsubscribe-incoming=patchwork.ozlabs.org@gcc.gnu.org>","List-Archive":"<http://gcc.gnu.org/ml/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-help@gcc.gnu.org>","Sender":"gcc-patches-owner@gcc.gnu.org","X-Virus-Found":"No","X-Spam-SWARE-Status":"No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD,\n\tSPF_HELO_PASS autolearn=ham version=3.3.2 spammy=","X-Spam-User":"qpsmtpd, 2 recipients","X-HELO":"mx1.redhat.com","DMARC-Filter":"OpenDMARC Filter v1.3.2 mx1.redhat.com 24B447E431","Date":"Tue, 19 Sep 2017 18:07:29 +0100","From":"Jonathan Wakely <jwakely@redhat.com>","To":"Tim Shen <timshen@google.com>","Cc":"libstdc++ <libstdc++@gcc.gnu.org>, gcc-patches <gcc-patches@gcc.gnu.org>","Subject":"Re: [libstdc++/71500] make back reference work with icase","Message-ID":"<20170919170729.GN4582@redhat.com>","References":"<CAG4ZjN=teuigpysiMSm+tE+3S4dm+WM=7n7A80gXBDFpdqfhBQ@mail.gmail.com>\n\t<20170915153954.GH4582@redhat.com>\n\t<20170918172617.GI4582@redhat.com>\n\t<CAG4ZjN=ioGfbwB+95ns=MaOAP0++UP9ZLwzex1fGcU7+DSxWMQ@mail.gmail.com>\n\t<20170918230148.GK4582@redhat.com>\n\t<CAG4ZjNkcGpcgQfp9JcTYyJiAiWupbYUdE-G=tCeWmBzesTfFqg@mail.gmail.com>\n\t<20170919143858.GL4582@redhat.com>","MIME-Version":"1.0","Content-Type":"multipart/mixed; boundary=\"TRkqPRiqIDKgfg/F\"","Content-Disposition":"inline","In-Reply-To":"<20170919143858.GL4582@redhat.com>","X-Clacks-Overhead":"GNU Terry Pratchett","User-Agent":"Mutt/1.8.3 (2017-05-23)"}}]