220 36973 <96975ffe-e956-4c04-b8bf-140a6520bfd2@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: frederik.hertzum@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Add std::begin and std::end for regular expression iterators
Date: Tue, 20 Feb 2018 00:35:28 -0800 (PST)
Lines: 95
Approved: news@gmane.org
Message-ID: <96975ffe-e956-4c04-b8bf-140a6520bfd2@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_15160_1828667455.1519115728312"
X-Trace: blaine.gmane.org 1519115627 20986 195.159.176.226 (20 Feb 2018 08:33:47 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 20 Feb 2018 08:33:47 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCZJN6FD4AKRBUN3V7KAKGQEQ54GBAI@isocpp.org Tue Feb 20 09:33:42 2018
Return-path: <std-proposals+bncBCZJN6FD4AKRBUN3V7KAKGQEQ54GBAI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f70.google.com ([209.85.213.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCZJN6FD4AKRBUN3V7KAKGQEQ54GBAI@isocpp.org>)
	id 1eo3Ma-00041g-EE
	for gclcip-std-proposals@m.gmane.org; Tue, 20 Feb 2018 09:33:24 +0100
Original-Received: by mail-vk0-f70.google.com with SMTP id n135sf8126676vke.9
        for <gclcip-std-proposals@m.gmane.org>; Tue, 20 Feb 2018 00:35:31 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=0l9es68q7fZJb2lx1JGse7+68DpCdVi4xuQOljGzDiI=;
        b=NsJWkiwOx9RG9mVaYV8VNE25962p6tMPwciMhzuvlaipt4JiOYNu7HVhdApaBkmwzY
         b7zIHvqidaN5JUBsHBxUWC3Z/5jyMv6Eg07YC7SEq7KsdLX+yzfN5qv39oPfywuXpN0v
         ULCbIw2i2N+jo08Z5GvYdhc5IKmR9hwXVrqg635L3orWhnhEaiNtjs1XjQ2zxIDA7qut
         gVzfJD0XHQou8BXZVtsxGfQoglvr+12YawcmeSY8gtQ6fB+08q5E1uz2LkspPCZgwTh/
         fRroVEaIBbHx8lyTvt+pjwpiz87aOM1YkZyztvxh3uGW7v2bH9v27BN8MiTM3UHaHphg
         cxWA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=0l9es68q7fZJb2lx1JGse7+68DpCdVi4xuQOljGzDiI=;
        b=DY3znVyoCLLrIe8xsRL2YUsPaRXuDWU0E0OR4WNbGspxBOO4HJhkGwbpM4FIxrcOxM
         EozC2/k9P9PU7eEM3gU3B/s68XsVzxHzIQZWUydOmHBYi6Ucns92z6ecfY/sIwUw6x7T
         LBurJd7MRf3eJXMykgoy0k+0OJLXuK/E7rdkqw03YM6xMYtmxAhLrKfCYNzTekONhTm0
         aBoZJZ/K5PC1fU38XlyI2aefAoib0chU+mEBW8ivb+fcVMnoUCFnIxX9q1Up7bXYNV8Q
         Fg3ke1447j476PcTHzyqNEJ5KIsKyGPpdLYBLm+w2Rml6vtrXwLsXBTV6qX+9rJ9eIgH
         emNQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=0l9es68q7fZJb2lx1JGse7+68DpCdVi4xuQOljGzDiI=;
        b=fsh2vd7eq9BP4pqZisOZJBGqGyhG0AAN6JLPl1RnoyeEN6PjCs0Uayk9Q/FeNwIIl+
         yI4Abw3bOaT9SPif30cYtTxo1Mjde7xpxA7Tx4Kpi7eoQ0ytnGISQsGPEbvEds8PZ1/7
         Ov/z9QXwmk3ChDbgQxbv+q28Wfj266fypRoGXXh4weYzKPerPzPms7qmfXQslGxANJbQ
         fgELpHWCMPGwyxcz2Aqw1mU2uPbFqew6/Sst52PMdGpdykF0pKxQSXirI5/6RG4p5w8+
         wvloFaKYDAwGCz3+lhsCxQ/NU3KYaQQUtn0vjsgmtj+KcTuKT7RUCVmGyxass00S7Lvi
         Lw0g==
X-Gm-Message-State: APf1xPAqP+rnWXFcNbwo83H11V8anwJ2PWZ+babvmgH43zbw9vPzRGuM
	zhQOBHeGvgbo603M1YuA0Rw7Ig==
X-Google-Smtp-Source: AH8x224o1PrLsjdFPmtVJOTNdXHLLSK5wNhIzrs2IJ5QQ0VX1/KPd9SY8S+6vgH8PaJfpyiZYR6v6A==
X-Received: by 10.31.10.137 with SMTP id 131mr2651031vkk.85.1519115730481;
        Tue, 20 Feb 2018 00:35:30 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.31.148.73 with SMTP id w70ls800536vkd.18.gmail; Tue, 20 Feb
 2018 00:35:28 -0800 (PST)
X-Received: by 10.31.182.77 with SMTP id g74mr1941945vkf.12.1519115728663;
        Tue, 20 Feb 2018 00:35:28 -0800 (PST)
X-Original-Sender: frederik.hertzum@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:36973
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/36973>

------=_Part_15160_1828667455.1519115728312
Content-Type: multipart/alternative; 
	boundary="----=_Part_15161_1583106779.1519115728312"

------=_Part_15161_1583106779.1519115728312
Content-Type: text/plain; charset="UTF-8"

Currently, it is not possible to use extended for-loops with stuff like 
std::sregex_iterator, because there is no .begin()/.end() pair and no 
std::begin/std::end pair for std::sregex_iterator -- adding an overload for 
std::sregex_iterator to the std-namespace is trivial and doing so will 
allow using them in extended for-loops.

I'm already doing this in production code and so far, have found no issues 
with it.

My implementation is fairly simple: std::begin(std::sregex_iterator&) 
returns the argument and std::end(std::sregex_iterator&) return a default 
constructed std::sregex_iterator:


namespace std {
auto end(std::sregex_iterator& ) -> std::sregex_iterator& {
static std::sregex_iterator end_of_sequence_iterator;
return end_of_sequence_iterator;
}

auto begin(std::sregex_iterator& b) -> std::sregex_iterator& {
return b;
}
}

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/96975ffe-e956-4c04-b8bf-140a6520bfd2%40isocpp.org.

------=_Part_15161_1583106779.1519115728312
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Currently, it is not possible to use extended for-loops wi=
th stuff like std::sregex_iterator, because there is no <font face=3D"couri=
er new, monospace">.begin()</font>/<font face=3D"courier new, monospace">.e=
nd()</font>=C2=A0pair and no <font face=3D"courier new, monospace">std::beg=
in</font>/<font face=3D"courier new, monospace">std::end</font> pair for <f=
ont face=3D"courier new, monospace">std::sregex_iterator</font> -- adding a=
n overload for <font face=3D"courier new, monospace">std::sregex_iterator</=
font> to the <font face=3D"courier new, monospace">std</font>-namespace is =
trivial and doing so will allow using them in extended for-loops.<div><br><=
/div><div>I&#39;m already doing this in production code and so far, have fo=
und no issues with it.</div><div><br></div><div>My implementation is fairly=
 simple: <font face=3D"courier new, monospace">std::begin(std::sregex_itera=
tor&amp;)</font> returns the argument and <font face=3D"courier new, monosp=
ace">std::end(std::sregex_iterator&amp;)</font> return a default constructe=
d <font face=3D"courier new, monospace">std::sregex_iterator</font>:</div><=
div><font face=3D"courier new, monospace"><br></font></div><div><div><font =
face=3D"courier new, monospace"><br></font></div><div><font face=3D"courier=
 new, monospace">namespace std {</font></div><div><font face=3D"courier new=
, monospace"><span style=3D"white-space:pre">	</span>auto end(std::sregex_i=
terator&amp; ) -&gt; std::sregex_iterator&amp; {</font></div><div><font fac=
e=3D"courier new, monospace"><span style=3D"white-space:pre">			</span>stat=
ic std::sregex_iterator end_of_sequence_iterator;</font></div><div><font fa=
ce=3D"courier new, monospace"><span style=3D"white-space:pre">			</span>ret=
urn end_of_sequence_iterator;</font></div><div><font face=3D"courier new, m=
onospace"><span style=3D"white-space:pre">	</span>}</font></div><div><font =
face=3D"courier new, monospace"><br></font></div><div><font face=3D"courier=
 new, monospace"><span style=3D"white-space:pre">	</span>auto begin(std::sr=
egex_iterator&amp; b) -&gt; std::sregex_iterator&amp; {</font></div><div><f=
ont face=3D"courier new, monospace"><span style=3D"white-space:pre">		</spa=
n>return b;</font></div><div><font face=3D"courier new, monospace"><span st=
yle=3D"white-space:pre">	</span>}</font></div><div><font face=3D"courier ne=
w, monospace">}</font></div></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/96975ffe-e956-4c04-b8bf-140a6520bfd2%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/96975ffe-e956-4c04-b8bf-140a6520bfd2=
%40isocpp.org</a>.<br />

------=_Part_15161_1583106779.1519115728312--

------=_Part_15160_1828667455.1519115728312--

.
