Topic: <algorithm> extract/extract_between
Author: germinolegrand@gmail.com
Date: Sun, 23 Feb 2014 14:26:05 -0800 (PST)
Raw View
------=_Part_884_14318831.1393194365974
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Hello,
Here is an algorithm i often need, and often use because it amazingly=20
simplifies the code readability, and suppresses hours of debugging=20
headaches.
If i had to write a cppreference entry about it, it would look like that :
*std::extract, std::extract_if, std::extract_between,=20
std::extract_between_if*
template< class InputIt, class A, class B >
std::pair <http://en.cppreference.com/w/cpp/utility/pair><InputIt,InputIt>=
=20
extract(InputIt first, InputIt last, A const& begin_value, B const&end_=
value
); (1)
template< class InputIt, class UnaryPredicateA, class UnaryPredicateB >
std::pair <http://en.cppreference.com/w/cpp/utility/pair><InputIt,InputIt>=
=20
extract_if(InputIt first, InputIt last, UnaryPredicateA begin_p,=20
UnaryPredicateB end_p); (2)
template< class InputIt, class A, class B >
std::pair <http://en.cppreference.com/w/cpp/utility/pair><InputIt,InputIt>=
=20
extract_between(InputIt first, InputIt last, A const& begin_value, B=20
const& end_value); (3)
template< class InputIt, class UnaryPredicateA, class UnaryPredicateB >
std::pair <http://en.cppreference.com/w/cpp/utility/pair><InputIt,InputIt>=
=20
extract_between_if(InputIt first, InputIt last, UnaryPredicateA begin_p=
,=20
UnaryPredicateB end_p); (4)
Returns the first range in the range [first, last) that satisfies specific=
=20
criteria:
1) the first element is equal to begin_value, and except the first element=
=20
only the last element may be equal to end_value
2) the first element is an element for which predicate begin_p returns true=
,=20
and except the first element only the last element may be an element for=20
which predicate p returns true
3) the element before the first element is equal to begin_value, and except=
=20
the element before the first element only the element after the last=20
element may be equal to end_value
4) the element before the first element is an element for which predicate=
=20
begin_p returns true, and except the element before the first element only=
=20
the element after the last element may be an element for which predicate pr=
eturns=20
true
Parameters first, last - the range of elements to examine begin_value,=
=20
end_value - values to compare the elements to begin_p, end_p - unary=20
predicates which return =E2=80=8Btrue for the required element.=20
The signature of the predicate functions should be equivalent to the=20
following:=20
bool pred(const Type &a);=20
The signature does not need to have const &, but the functions must not=20
modify the objects passed to it.
The type Type must be such that an object of type InputIt can be=20
dereferenced and then implicitly converted to Type. =E2=80=8B=20
Type requirements -InputIt must meet the requirements of InputIterator<ht=
tp://en.cppreference.com/w/cpp/concept/InputIterator>.=20
-UnaryPredicate must meet the requirements of Predicate<http://en.cpprefer=
ence.com/w/cpp/concept/Predicate>.=20
=20
Return value=20
std::pair <http://en.cppreference.com/w/cpp/utility/pair> containing a pair=
=20
of iterators defining the wanted range, the first pointing to the first=20
element satisfying the condition ((1) (2)) or the element after the first=
=20
element satisfying the condition and the second pointing to the first=20
element *greater* than value.=20
If there are no elements satisfying the condition for the first, last is=20
returned as the first element. Similarly if there are no elements=20
satisfying the condition for the second, last is returned as the second=20
element.
Complexity=20
At most last - first applications of one of the two predicats.=20
Possible implementation First version
template<class InputIt, class A, class B>
std::pair<InputIt, InputIt> extract(InputIt first, InputIt last, A const& b=
egin_value, B const& end_value)
{
first =3D std::find(first, last, begin_value);
InputIt sub_last =3D std::find(first, last, end_value);
if(sub_last !=3D last)
++sub_last;
return {first, sub_last};
}
Second version
template<class InputIt, class A, class B>
std::pair<InputIt, InputIt> extract_if(InputIt first, InputIt last, A begin=
_p, B end_p)
{
first =3D std::find_if(first, last, begin_p);
InputIt sub_last =3D std::find_if(first, last, end_p);
if(sub_last !=3D last)
++sub_last;
return {first, sub_last};
}
=20
Third version
template<class InputIt, class A, class B>
std::pair<InputIt, InputIt> extract_between(InputIt first, InputIt last, A =
const& begin_value, B const& end_value)
{
first =3D std::find(first, last, a);
if(first !=3D last)
++first;
return {first, std::find(first, last, b)};
}
Fourth version
template<class InputIt, class A, class B>
std::pair<InputIt, InputIt> extract_between_if(InputIt first, InputIt last,=
A begin_p, B const& end_p)
{
first =3D std::find_if(first, last, a);
if(first !=3D last)
++first;
return {first, std::find_if(first, last, b)};
}
Example=20
The following example finds a tag in a vector of char representing a list=
=20
of tags.=20
Run this code
#include <iostream>
#include <algorithm>
#include <string>
=20
int main()
{
std::vector<int> v =3D {1, 2, 5, 4, 6, 2, 3, 4};
auto result1_pair_it =3D std::extract(std::begin <http://en.cppreferenc=
e.com/w/cpp/iterator/begin>(v), std::end <http://en.cppreference.com/w/cpp/=
iterator/end>(v), 5, 2);
std::vector result1(result1_pair_it.first, result1_pair_it.second);
for(auto i : result1)
std::cout << i << ' ';
std::cout << '\n';
auto result2_pair_it =3D std::extract_between(std::begin <http://en.cpp=
reference.com/w/cpp/iterator/begin>(v), std::end <http://en.cppreference.co=
m/w/cpp/iterator/end>(v), 5, 2);
std::vector result2(result2_pair_it.first, result2_pair_it.second);
for(auto i : result2)
std::cout << i << ' ';
std::cout << '\n';
auto result3_pair_it =3D std::extract_between_if(std::begin <http://en.=
cppreference.com/w/cpp/iterator/begin>(v), std::end <http://en.cppreference=
..com/w/cpp/iterator/end>(v),
[](int i){ return i > 5;=
},
[](int i){ return i > 10=
; });
std::vector result3(result3_pair_it.first, result3_pair_it.second);
for(auto i : result3)
std::cout << i << ' ';
}
Output:=20
5 4 6 2=20
4 6=20
2 3 4
I hope you understand the utility of this algorithm. Using it on string is=
=20
frequent too... saves up a lot of substr and find...
As i heard the committee wants new algorithms, what would you recommand=20
about this algorithm ? Is there already a proposal for such an algorithm ?=
=20
Is there any modification to be made on it so that it fits better to the=20
STL ?
Thanks for reading at least.
germinolegrand
--=20
---=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_884_14318831.1393194365974
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hello,<br><br>Here is an algorithm i often need, and often=
use because it amazingly simplifies the code readability, and suppresses h=
ours of debugging headaches.<br><br>If i had to write a cppreference entry =
about it, it would look like that :<br><br><font size=3D"4"><b>std::extract=
, std::extract_if, std::extract_between, std::extract_between_if</b></font>=
<br><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250=
); border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px=
; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subpret=
typrint"><br><div><span class=3D"mw-geshi cpp source-cpp"><span class=3D"kw=
1"><span style=3D"color: #008;" class=3D"styled-by-prettify">template</span=
></span><span class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by=
-prettify"><</span></span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span class=3D"kw1"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">class</span></span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"sty=
led-by-prettify">InputIt</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span class=3D"kw1"><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">class</span></span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> A</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> B </span><sp=
an class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-prettify">=
></span></span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br></span><p><a href=3D"http://en.cppreference.com/w/cpp/utility/pair"><s=
pan class=3D"kw901"><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</=
span><span class=3D"me2"><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">pair</span></span></span></a><span class=3D"sy1"><span style=3D"col=
or: #660;" class=3D"styled-by-prettify"><</span></span><code class=3D"pr=
ettyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"></span><span style=3D"color: #606;" class=
=3D"styled-by-prettify">InputIt</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify"></span></span></code><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><code class=3D"prettyprint"><span class=3D=
"mw-geshi cpp source-cpp"><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"></span><span style=3D"color: #606;" class=3D"styled-by-prettify">I=
nputIt</span><span style=3D"color: #660;" class=3D"styled-by-prettify"></sp=
an></span></code><span class=3D"sy1"><span style=3D"color: #660;" class=3D"=
styled-by-prettify">></span></span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> <br> ex</span><span class=3D"br0"><span =
style=3D"color: #000;" class=3D"styled-by-prettify">tract</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span></span><code class=
=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"></span><span style=3D"color: #606;"=
class=3D"styled-by-prettify">InputIt</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify"> </span></span></code><span style=3D"color: #000=
;" class=3D"styled-by-prettify">first</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><code class=3D"prettyprint"><span class=3D"mw-ges=
hi cpp source-cpp"><span style=3D"color: #000;" class=3D"styled-by-prettify=
"></span><span style=3D"color: #606;" class=3D"styled-by-prettify">InputIt<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify"> </span></s=
pan></code><span style=3D"color: #008;" class=3D"styled-by-prettify">last</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><spa=
n class=3D"kw4"><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
A </span><span style=3D"color: #008;" class=3D"styled-by-prettify">const</s=
pan></span><span class=3D"sy3"><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&</span></span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> begin_value</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span class=3D"br0"><span style=3D"color: #000;" class=3D"=
styled-by-prettify">B </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">const</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">&</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> end_value</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">)</span></span><span class=3D"sy4"><span style=3D"color: #660;" class=3D"=
styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> (1)<br></span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"></span></span><br><code class=3D"prettyprint"><span class=3D"mw-ge=
shi cpp source-cpp"><span class=3D"kw1"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span></span><span class=3D"sy1"><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify"><</span></span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span class=3D"kw=
1"><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span></=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></sp=
an></code><code class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cp=
p"><span style=3D"color: #000;" class=3D"styled-by-prettify"><code class=3D=
"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"color:=
#000;" class=3D"styled-by-prettify"></span><span style=3D"color: #606;" cl=
ass=3D"styled-by-prettify">InputIt</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"></span></span></code></span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span class=3D"kw1"><span style=3D"color:=
#008;" class=3D"styled-by-prettify">class</span></span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span></span></code><code class=3D=
"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"color:=
#000;" class=3D"styled-by-prettify"><span class=3D"mw-geshi cpp source-cpp=
">UnaryPredicateA</span></span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">clas=
s</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
/span></code><code class=3D"prettyprint"><span class=3D"mw-geshi cpp source=
-cpp"><span style=3D"color: #000;" class=3D"styled-by-prettify"><span class=
=3D"mw-geshi cpp source-cpp">UnaryPredicate</span>B </span><span class=3D"s=
y1"><span style=3D"color: #660;" class=3D"styled-by-prettify">></span></=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><=
/span></code></p><p><code class=3D"prettyprint"><a href=3D"http://en.cppref=
erence.com/w/cpp/utility/pair"><span class=3D"kw901"><span style=3D"color: =
#000;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">::</span><span class=3D"me2"><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">pair</span></span></span></a><span=
class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-prettify">&l=
t;</span></span><code class=3D"prettyprint"><span class=3D"mw-geshi cpp sou=
rce-cpp"><span style=3D"color: #000;" class=3D"styled-by-prettify"></span><=
span style=3D"color: #606;" class=3D"styled-by-prettify">InputIt</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify"></span></span></code>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><code cla=
ss=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"></span><span style=3D"color: #606=
;" class=3D"styled-by-prettify">InputIt</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify"></span></span></code><span class=3D"sy1"><span=
style=3D"color: #660;" class=3D"styled-by-prettify">></span></span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> <br> ex=
</span><span class=3D"br0"><span style=3D"color: #000;" class=3D"styled-by-=
prettify">tract</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">_if(</span></span><code class=3D"prettyprint"><span class=3D"mw-geshi =
cpp source-cpp"><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
/span><span style=3D"color: #606;" class=3D"styled-by-prettify">InputIt</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify"> </span></span=
></code><span style=3D"color: #000;" class=3D"styled-by-prettify">first</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> </span><code class=3D"=
prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"color: =
#000;" class=3D"styled-by-prettify"></span><span style=3D"color: #606;" cla=
ss=3D"styled-by-prettify">InputIt</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"> </span></span></code><span style=3D"color: #008;" =
class=3D"styled-by-prettify">last</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span class=3D"kw4"><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span></span><span class=3D"kw4"><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><span class=3D"mw-gesh=
i cpp source-cpp">UnaryPredicate</span>A</span></span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> begin_p</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span class=3D"mw-geshi cpp source-cpp">U=
naryPredicate</span><span class=3D"br0"><span style=3D"color: #000;" class=
=3D"styled-by-prettify">B</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> end_p</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">)</span></span><span class=3D"sy4"><span style=3D"color: #660;" =
class=3D"styled-by-prettify">; (2)<br></span></span></code></p></span><p></=
p><span style=3D"color: #000;" class=3D"styled-by-prettify"></span><br><cod=
e class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span class=
=3D"kw1"><span style=3D"color: #008;" class=3D"styled-by-prettify">template=
</span></span><span class=3D"sy1"><span style=3D"color: #660;" class=3D"sty=
led-by-prettify"><</span></span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span class=3D"kw1"><span style=3D"color: #008;" =
class=3D"styled-by-prettify">class</span></span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span></span></code><code class=3D"prettyp=
rint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><code class=3D"prettyprint"><span class=3D"mw-=
geshi cpp source-cpp"><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"></span><span style=3D"color: #606;" class=3D"styled-by-prettify">Input=
It</span><span style=3D"color: #660;" class=3D"styled-by-prettify"></span><=
/span></code></span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </spa=
n><span class=3D"kw1"><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">class</span></span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> A</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> B </span><span class=3D=
"sy1"><span style=3D"color: #660;" class=3D"styled-by-prettify">></span>=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span=
><p><a href=3D"http://en.cppreference.com/w/cpp/utility/pair"><span class=
=3D"kw901"><span style=3D"color: #000;" class=3D"styled-by-prettify">std</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><spa=
n class=3D"me2"><span style=3D"color: #000;" class=3D"styled-by-prettify">p=
air</span></span></span></a><span class=3D"sy1"><span style=3D"color: #660;=
" class=3D"styled-by-prettify"><</span></span><code class=3D"prettyprint=
"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"></span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">InputIt</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify"></span></span></code><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">,</span><code class=3D"prettyprint"><span class=3D"mw-geshi=
cpp source-cpp"><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">InputIt</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"></span></span=
></code><span class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by=
-prettify">></span></span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> <br> ex</span><span class=3D"br0"><span style=3D"=
color: #000;" class=3D"styled-by-prettify">tract_between</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span></span><code class=
=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"></span><span style=3D"color: #606;"=
class=3D"styled-by-prettify">InputIt</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify"> </span></span></code><span style=3D"color: #000=
;" class=3D"styled-by-prettify">first</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><code class=3D"prettyprint"><span class=3D"mw-ges=
hi cpp source-cpp"><span style=3D"color: #000;" class=3D"styled-by-prettify=
"></span><span style=3D"color: #606;" class=3D"styled-by-prettify">InputIt<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify"> </span></s=
pan></code><span style=3D"color: #008;" class=3D"styled-by-prettify">last</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><spa=
n class=3D"kw4"><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
A </span><span style=3D"color: #008;" class=3D"styled-by-prettify">const</s=
pan></span><span class=3D"sy3"><span style=3D"color: #660;" class=3D"styled=
-by-prettify">&</span></span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> begin_value</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span class=3D"br0"><span style=3D"color: #000;" class=3D"=
styled-by-prettify">B </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">const</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">&</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> end_value</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">)</span></span><span class=3D"sy4"><span style=3D"color: #660;" class=3D"=
styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> (3)<br></span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"></span></span><br><code class=3D"prettyprint"><span class=3D"mw-ge=
shi cpp source-cpp"><span class=3D"kw1"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span></span><span class=3D"sy1"><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify"><</span></span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span class=3D"kw=
1"><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span></=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></sp=
an></code><code class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cp=
p"><span style=3D"color: #000;" class=3D"styled-by-prettify"><code class=3D=
"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"color:=
#000;" class=3D"styled-by-prettify"></span><span style=3D"color: #606;" cl=
ass=3D"styled-by-prettify">InputIt</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"></span></span></code></span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </span><span class=3D"kw1"><span style=3D"color:=
#008;" class=3D"styled-by-prettify">class</span></span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span></span></code><code class=3D=
"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"color:=
#000;" class=3D"styled-by-prettify"><span class=3D"mw-geshi cpp source-cpp=
">UnaryPredicateA</span></span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">clas=
s</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
/span></code><code class=3D"prettyprint"><span class=3D"mw-geshi cpp source=
-cpp"><span style=3D"color: #000;" class=3D"styled-by-prettify"><span class=
=3D"mw-geshi cpp source-cpp">UnaryPredicate</span>B </span><span class=3D"s=
y1"><span style=3D"color: #660;" class=3D"styled-by-prettify">></span></=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"></span></spa=
n><a href=3D"http://en.cppreference.com/w/cpp/utility/pair"><span class=3D"=
kw901"><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>std</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><spa=
n class=3D"me2"><span style=3D"color: #000;" class=3D"styled-by-prettify">p=
air</span></span></span></a><span class=3D"sy1"><span style=3D"color: #660;=
" class=3D"styled-by-prettify"><</span></span></code><code class=3D"pret=
typrint"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-b=
y-prettify"><code class=3D"prettyprint"><span class=3D"mw-geshi cpp source-=
cpp"><span style=3D"color: #000;" class=3D"styled-by-prettify"></span><span=
style=3D"color: #606;" class=3D"styled-by-prettify">InputIt</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify"></span></span></code></sp=
an></span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
></code><code class=3D"prettyprint"><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify"><code class=3D"prettyprint"><span class=3D"mw-geshi cpp =
source-cpp"><span style=3D"color: #000;" class=3D"styled-by-prettify"></spa=
n><span style=3D"color: #606;" class=3D"styled-by-prettify">InputIt</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify"></span></span></co=
de></span><span class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-=
by-prettify">></span></span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> <br> ex</span><span class=3D"br0"><span style=
=3D"color: #000;" class=3D"styled-by-prettify">tract_</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">between_if(</span></span></code>=
<code class=3D"prettyprint"><span class=3D"br0"><span style=3D"color: #660;=
" class=3D"styled-by-prettify"><code class=3D"prettyprint"><span class=3D"m=
w-geshi cpp source-cpp"><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"></span><span style=3D"color: #606;" class=3D"styled-by-prettify">Inp=
utIt</span><span style=3D"color: #660;" class=3D"styled-by-prettify"> </spa=
n></span></code></span></span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">first</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span></code><code class=3D"prettyprint"><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><code class=3D"prettyprint"><span class=3D"mw-gesh=
i cpp source-cpp"><span style=3D"color: #000;" class=3D"styled-by-prettify"=
></span><span style=3D"color: #606;" class=3D"styled-by-prettify">InputIt</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify"> </span></sp=
an></code></span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
last</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</spa=
n><span class=3D"kw4"><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </span></span><span class=3D"kw4"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><span class=3D"mw-geshi cpp source-cpp">UnaryPredic=
ate</span>A</span></span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> begin_p</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span class=3D"mw-geshi cpp source-cpp">UnaryPredicate</span><span cla=
ss=3D"br0"><span style=3D"color: #000;" class=3D"styled-by-prettify">B</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> end_p</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">)</span></span><spa=
n class=3D"sy4"><span style=3D"color: #660;" class=3D"styled-by-prettify">;=
(4)<br></span></span></code></p></span></code></div></div></code></div>
<p>Returns the first range in the range <code>[first, last)</code> that sat=
isfies specific criteria:</p><p>1) the first element is equal to <code clas=
s=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">begin_value</span></span></code>, =
and except the first element only the last element may be equal to <code cl=
ass=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span class=3D"=
br0"><span style=3D"color: #000;" class=3D"styled-by-prettify">end_value</s=
pan></span></span></code><br></p><p>2) the first element is an element for =
which predicate <code>begin_p</code> returns <span class=3D"t-c"><span clas=
s=3D"mw-geshi cpp source-cpp"><span class=3D"kw2">true</span></span></span>=
, and except the first element only the last element may be an element for =
which predicate <code>p</code> returns <span class=3D"t-c"><span class=3D"m=
w-geshi cpp source-cpp"><span class=3D"kw2">true</span></span></span><br></=
p><p>3) the element before the first element is equal to <code class=3D"pre=
ttyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">begin_value</span></span></code>, and exce=
pt the element before the first element only the element after the last ele=
ment may be equal to <code class=3D"prettyprint"><span class=3D"mw-geshi cp=
p source-cpp"><span class=3D"br0"><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">end_value</span></span></span></code><br></p><p>4) the ele=
ment before the first element is an element for which predicate <code>begin=
_p</code> returns <span class=3D"t-c"><span class=3D"mw-geshi cpp source-cp=
p"><span class=3D"kw2">true</span></span></span>, and except the element be=
fore the first element only the element after the last element may be an el=
ement for which predicate <code>p</code> returns <span class=3D"t-c"><span =
class=3D"mw-geshi cpp source-cpp"><span class=3D"kw2">true</span></span></s=
pan></p><h3><span class=3D"mw-headline" id=3D"Parameters">Parameters</span>=
</h3>
<table class=3D"t-par-begin">
<tbody><tr class=3D"t-par">
<td> first, last
</td>
<td> -
</td>
<td> the range of elements to examine
</td></tr>
<tr class=3D"t-par">
<td> begin_value, end_value
</td>
<td> -
</td>
<td> values to compare the elements to
</td></tr>
<tr class=3D"t-par">
<td> begin_p, end_p
</td>
<td> -
</td>
<td>unary predicates which return =E2=80=8B<span class=3D"t-c"><span class=
=3D"mw-geshi cpp source-cpp"><span class=3D"kw2">true</span></span></span> =
for the required element. <br>
<p>The signature of the predicate functions should be equivalent to the fol=
lowing:
</p><p><span class=3D"t-cc"><span class=3D"mw-geshi cpp source-cpp"> <=
span class=3D"kw4">bool</span> pred<span class=3D"br0">(</span><span class=
=3D"kw4">const</span> Type <span class=3D"sy3">&</span>a<span class=3D"=
br0">)</span><span class=3D"sy4">;</span></span></span>
</p><p>The signature does not need to have <span class=3D"t-c"><span class=
=3D"mw-geshi cpp source-cpp"><span class=3D"kw4">const</span> <span class=
=3D"sy3">&</span></span></span>, but the functions must not modify the =
objects passed to it.<br>
The type <span class=3D"t-c"><span class=3D"mw-geshi cpp source-cpp">Type</=
span></span> must be such that an object of type <span class=3D"t-c"><span =
class=3D"mw-geshi cpp source-cpp">InputIt</span></span> can be dereferenced=
and then implicitly converted to <span class=3D"t-c"><span class=3D"mw-ges=
hi cpp source-cpp">Type</span></span>.
=E2=80=8B
</p></td></tr>
<tr class=3D"t-par-hitem">
<td colspan=3D"3"><table class=3D"t-par-begin"><tbody><tr class=3D"t-par-hi=
tem"><td colspan=3D"3">Type requirements
</td></tr>
<tr class=3D"t-par-req">
<td colspan=3D"3"> -<code>InputIt</code> must meet the requirements of <a h=
ref=3D"http://en.cppreference.com/w/cpp/concept/InputIterator" title=3D"cpp=
/concept/InputIterator"><code>InputIterator</code></a>.
</td></tr>
<tr class=3D"t-par-req">
<td colspan=3D"3"> -<code>UnaryPredicate</code> must meet the requirements =
of <a href=3D"http://en.cppreference.com/w/cpp/concept/Predicate" title=3D"=
cpp/concept/Predicate"><code>Predicate</code></a>.
</td></tr></tbody></table></td></tr>
<tr class=3D"t-par-req">
<td colspan=3D"3"><br></td></tr></tbody></table><h3><br><span class=3D"mw-h=
eadline" id=3D"Return_value"></span></h3><h3><span class=3D"mw-headline" id=
=3D"Return_value">Return value</span></h3>
<p><span class=3D"t-lc"><a href=3D"http://en.cppreference.com/w/cpp/utility=
/pair" title=3D"cpp/utility/pair">std::pair</a></span> containing a pair of=
iterators defining the wanted range, the first pointing to the first eleme=
nt satisfying the condition ((1) (2)) or the element after<code></code> th=
e first element satisfying the condition and the second pointing to the fir=
st element <i>greater</i> than <code>value</code>.=20
</p><p>If there are no elements satisfying the condition for the first<code=
></code><i><code></code></i><code></code>, <code>last</code> is returned as=
the first element. Similarly if there are no elements satisfying the condi=
tion for the second<code></code>, <code>last</code> is returned as the seco=
nd element.</p><h3><span class=3D"mw-headline" id=3D"Complexity">Complexity=
</span></h3>
<p>At most <code>last</code> - <code>first</code> applications of one of th=
e two predicats. <br></p><h3><span class=3D"mw-headline" id=3D"Possible_imp=
lementation">Possible implementation</span></h3>
<table class=3D"eq-fun-cpp-table">
<tbody><tr>
<th> First version</th></tr><tr><td><div dir=3D"ltr" class=3D"mw-geshi" sty=
le=3D"text-align: left;"><div class=3D"cpp source-cpp"><pre class=3D"de1"><=
span class=3D"br0"><div class=3D"prettyprint" style=3D"background-color: rg=
b(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bo=
rder-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div c=
lass=3D"subprettyprint"><span style=3D"color: #606;" class=3D"styled-by-pre=
ttify">template<class </span><code class=3D"prettyprint"><code class=3D"=
prettyprint"><span class=3D"mw-geshi cpp source-cpp"><code class=3D"prettyp=
rint"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-p=
rettify"></span></span></code><code class=3D"prettyprint"><span class=3D"sy=
1"><span style=3D"color: #660;" class=3D"styled-by-prettify"><code class=3D=
"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"color:=
#000;" class=3D"styled-by-prettify"></span><span style=3D"color: #606;" cl=
ass=3D"styled-by-prettify">InputIt</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"></span></span></code></span></span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify"></span></code></span></code></cod=
e><span style=3D"color: #606;" class=3D"styled-by-prettify">, class A, clas=
s B><br>std::pair<</span><code class=3D"prettyprint"><code class=3D"p=
rettyprint"><span class=3D"mw-geshi cpp source-cpp"><code class=3D"prettypr=
int"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify"></span></span></code><code class=3D"prettyprint"><span class=3D"sy1=
"><span style=3D"color: #660;" class=3D"styled-by-prettify"><code class=3D"=
prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"color: =
#000;" class=3D"styled-by-prettify"></span><span style=3D"color: #606;" cla=
ss=3D"styled-by-prettify">InputIt</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify"></span></span></code></span></span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify"></span></code></span></code></cod=
e><span style=3D"color: #606;" class=3D"styled-by-prettify">, </span><code =
class=3D"prettyprint"><code class=3D"prettyprint"><span class=3D"mw-geshi c=
pp source-cpp"><code class=3D"prettyprint"><span class=3D"sy1"><span style=
=3D"color: #660;" class=3D"styled-by-prettify"></span></span></code><code c=
lass=3D"prettyprint"><span class=3D"sy1"><span style=3D"color: #660;" class=
=3D"styled-by-prettify"><code class=3D"prettyprint"><span class=3D"mw-geshi=
cpp source-cpp"><span style=3D"color: #000;" class=3D"styled-by-prettify">=
</span><span style=3D"color: #606;" class=3D"styled-by-prettify">InputIt</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"></span></span=
></code></span></span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify"></span></code></span></code></code><span style=3D"color: #606;" class=
=3D"styled-by-prettify">> extract(</span><code class=3D"prettyprint"><co=
de class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><code clas=
s=3D"prettyprint"><span class=3D"sy1"><span style=3D"color: #660;" class=3D=
"styled-by-prettify"></span></span></code><code class=3D"prettyprint"><span=
class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-prettify"><c=
ode class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"></span><span style=3D"colo=
r: #606;" class=3D"styled-by-prettify">InputIt</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify"></span></span></code></span></span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify"> </span></code></span=
></code></code><span style=3D"color: #606;" class=3D"styled-by-prettify"><c=
ode class=3D"prettyprint"><code class=3D"prettyprint"><span class=3D"mw-ges=
hi cpp source-cpp"><span style=3D"color: #660;" class=3D"styled-by-prettify=
">first</span></span></code></code>, </span><code class=3D"prettyprint"><co=
de class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><code clas=
s=3D"prettyprint"><span class=3D"sy1"><span style=3D"color: #660;" class=3D=
"styled-by-prettify"></span></span></code><code class=3D"prettyprint"><span=
class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-prettify"><c=
ode class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"></span><span style=3D"colo=
r: #606;" class=3D"styled-by-prettify">InputIt</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify"></span></span></code></span></span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify"> </span></code></span=
></code></code><span style=3D"color: #606;" class=3D"styled-by-prettify">la=
st, A const& begin_value, B const& end_value)<br>{<br> first =3D=
std::find(first, last, begin_value);<br><br> </span><code class=3D"pret=
typrint"><code class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp=
"><code class=3D"prettyprint"><span class=3D"sy1"><span style=3D"color: #66=
0;" class=3D"styled-by-prettify"></span></span></code><code class=3D"pretty=
print"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-=
prettify"><code class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cp=
p"><span style=3D"color: #000;" class=3D"styled-by-prettify"></span><span s=
tyle=3D"color: #606;" class=3D"styled-by-prettify">InputIt</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify"></span></span></code></span=
></span><span style=3D"color: #660;" class=3D"styled-by-prettify"> </span><=
/code></span></code></code><span style=3D"color: #606;" class=3D"styled-by-=
prettify">sub_last =3D std::find(first, last, end_value);<br><br> if(sub=
_last !=3D last)<br> ++sub_last;<br><br> return {first, sub_last}=
;<br>}</span><span style=3D"color: #660;" class=3D"styled-by-prettify"></sp=
an></div></code></div><br><br></span></pre></div></div>
</td></tr>
<tr>
<th> Second version</th></tr><tr><td><div dir=3D"ltr" class=3D"mw-geshi" st=
yle=3D"text-align: left;"><div class=3D"cpp source-cpp"><pre class=3D"de1">=
<span class=3D"br0"><div class=3D"prettyprint" style=3D"background-color: r=
gb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; b=
order-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div =
class=3D"subprettyprint"><span style=3D"color: #606;" class=3D"styled-by-pr=
ettify">template<class </span><code class=3D"prettyprint"><code class=3D=
"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><code class=3D"pretty=
print"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-=
prettify"></span></span></code><code class=3D"prettyprint"><span class=3D"s=
y1"><span style=3D"color: #660;" class=3D"styled-by-prettify"><code class=
=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"></span><span style=3D"color: #606;"=
class=3D"styled-by-prettify">InputIt</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify"></span></span></code></span></span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"></span></code></span></code>=
</code><span style=3D"color: #606;" class=3D"styled-by-prettify">, class A,=
class B><br>std::pair<</span><code class=3D"prettyprint"><code class=
=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><code class=3D"pre=
ttyprint"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-=
by-prettify"></span></span></code><code class=3D"prettyprint"><span class=
=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-prettify"><code cl=
ass=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"=
color: #000;" class=3D"styled-by-prettify"></span><span style=3D"color: #60=
6;" class=3D"styled-by-prettify">InputIt</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify"></span></span></code></span></span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify"></span></code></span></code=
></code><span style=3D"color: #606;" class=3D"styled-by-prettify">, </span>=
<code class=3D"prettyprint"><code class=3D"prettyprint"><span class=3D"mw-g=
eshi cpp source-cpp"><code class=3D"prettyprint"><span class=3D"sy1"><span =
style=3D"color: #660;" class=3D"styled-by-prettify"></span></span></code><c=
ode class=3D"prettyprint"><span class=3D"sy1"><span style=3D"color: #660;" =
class=3D"styled-by-prettify"><code class=3D"prettyprint"><span class=3D"mw-=
geshi cpp source-cpp"><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"></span><span style=3D"color: #606;" class=3D"styled-by-prettify">Input=
It</span><span style=3D"color: #660;" class=3D"styled-by-prettify"></span><=
/span></code></span></span><span style=3D"color: #660;" class=3D"styled-by-=
prettify"></span></code></span></code></code><span style=3D"color: #606;" c=
lass=3D"styled-by-prettify">> extract_if(</span><code class=3D"prettypri=
nt"><code class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><co=
de class=3D"prettyprint"><span class=3D"sy1"><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify"></span></span></code><code class=3D"prettyprint=
"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-prett=
ify"><code class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"></span><span style=
=3D"color: #606;" class=3D"styled-by-prettify">InputIt</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify"></span></span></code></span></s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify"> </span></cod=
e></span></code></code><span style=3D"color: #606;" class=3D"styled-by-pret=
tify"><code class=3D"prettyprint"><code class=3D"prettyprint"><span class=
=3D"mw-geshi cpp source-cpp"><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">first</span></span></code></code>, </span><code class=3D"pretty=
print"><code class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp">=
<code class=3D"prettyprint"><span class=3D"sy1"><span style=3D"color: #660;=
" class=3D"styled-by-prettify"></span></span></code><code class=3D"prettypr=
int"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify"><code class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"=
><span style=3D"color: #000;" class=3D"styled-by-prettify"></span><span sty=
le=3D"color: #606;" class=3D"styled-by-prettify">InputIt</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"></span></span></code></span>=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify"> </span></=
code></span></code></code><span style=3D"color: #606;" class=3D"styled-by-p=
rettify">last, A begin_p, B end_p)<br>{<br> first =3D std::find_if(first=
, last, begin_p);<br><br> </span><code class=3D"prettyprint"><code class=
=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><code class=3D"pre=
ttyprint"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-=
by-prettify"></span></span></code><code class=3D"prettyprint"><span class=
=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-prettify"><code cl=
ass=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"=
color: #000;" class=3D"styled-by-prettify"></span><span style=3D"color: #60=
6;" class=3D"styled-by-prettify">InputIt</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify"></span></span></code></span></span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify"> </span></code></span></cod=
e></code><span style=3D"color: #606;" class=3D"styled-by-prettify">sub_last=
=3D std::find_if(first, last, end_p);<br><br> if(sub_last !=3D last)<br=
> ++sub_last;<br><br> return {first, sub_last};<br>}</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify"></span></div></code></d=
iv></span></pre></div></div>
</td></tr>
<tr><th> <br>Third version</th></tr><tr><td><div dir=3D"ltr" class=3D"mw-ge=
shi" style=3D"text-align: left;"><div class=3D"cpp source-cpp"><pre class=
=3D"de1"><span class=3D"br0"><div class=3D"prettyprint" style=3D"background=
-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style:=
solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettypri=
nt"><div class=3D"subprettyprint"><span style=3D"color: #606;" class=3D"sty=
led-by-prettify">template<class </span><code class=3D"prettyprint"><code=
class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><code class=
=3D"prettyprint"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"=
styled-by-prettify"></span></span></code><code class=3D"prettyprint"><span =
class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-prettify"><co=
de class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"></span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">InputIt</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify"></span></span></code></span></span><span=
style=3D"color: #660;" class=3D"styled-by-prettify"></span></code></span><=
/code></code><span style=3D"color: #606;" class=3D"styled-by-prettify">, cl=
ass A, class B><br>std::pair<</span><code class=3D"prettyprint"><code=
class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><code class=
=3D"prettyprint"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"=
styled-by-prettify"></span></span></code><code class=3D"prettyprint"><span =
class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-prettify"><co=
de class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"></span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">InputIt</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify"></span></span></code></span></span><span=
style=3D"color: #660;" class=3D"styled-by-prettify"></span></code></span><=
/code></code><span style=3D"color: #606;" class=3D"styled-by-prettify">, </=
span><code class=3D"prettyprint"><code class=3D"prettyprint"><span class=3D=
"mw-geshi cpp source-cpp"><code class=3D"prettyprint"><span class=3D"sy1"><=
span style=3D"color: #660;" class=3D"styled-by-prettify"></span></span></co=
de><code class=3D"prettyprint"><span class=3D"sy1"><span style=3D"color: #6=
60;" class=3D"styled-by-prettify"><code class=3D"prettyprint"><span class=
=3D"mw-geshi cpp source-cpp"><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"></span><span style=3D"color: #606;" class=3D"styled-by-prettify=
">InputIt</span><span style=3D"color: #660;" class=3D"styled-by-prettify"><=
/span></span></code></span></span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify"></span></code></span></code></code><span style=3D"color: #=
606;" class=3D"styled-by-prettify">> extract_between(</span><code class=
=3D"prettyprint"><code class=3D"prettyprint"><span class=3D"mw-geshi cpp so=
urce-cpp"><code class=3D"prettyprint"><span class=3D"sy1"><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify"></span></span></code><code class=
=3D"prettyprint"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"=
styled-by-prettify"><code class=3D"prettyprint"><span class=3D"mw-geshi cpp=
source-cpp"><span style=3D"color: #000;" class=3D"styled-by-prettify"></sp=
an><span style=3D"color: #606;" class=3D"styled-by-prettify">InputIt</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify"></span></span></c=
ode></span></span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
> </span></code></span></code></code><span style=3D"color: #606;" class=3D"=
styled-by-prettify"><code class=3D"prettyprint"><code class=3D"prettyprint"=
><span class=3D"mw-geshi cpp source-cpp"><span style=3D"color: #660;" class=
=3D"styled-by-prettify">first</span></span></code></code>, </span><code cla=
ss=3D"prettyprint"><code class=3D"prettyprint"><span class=3D"mw-geshi cpp =
source-cpp"><code class=3D"prettyprint"><span class=3D"sy1"><span style=3D"=
color: #660;" class=3D"styled-by-prettify"></span></span></code><code class=
=3D"prettyprint"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"=
styled-by-prettify"><code class=3D"prettyprint"><span class=3D"mw-geshi cpp=
source-cpp"><span style=3D"color: #000;" class=3D"styled-by-prettify"></sp=
an><span style=3D"color: #606;" class=3D"styled-by-prettify">InputIt</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify"></span></span></c=
ode></span></span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
> </span></code></span></code></code><span style=3D"color: #606;" class=3D"=
styled-by-prettify">last, A const& begin_value, B const& end_value)=
<br>{<br> first =3D std::find(first, last, a);<br><br> if(first !=3D =
last)<br> ++first;<br><br> return {first, std::find(first, last, =
b)};<br>}</span><span style=3D"color: #606;" class=3D"styled-by-prettify"><=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify"></span></di=
v></code></div><br></span></pre></div></div>
</td></tr><tr><th><table class=3D"eq-fun-cpp-table"><tbody><tr><th> Fourth =
version</th></tr><tr><td><div dir=3D"ltr" class=3D"mw-geshi" style=3D"text-=
align: left;"><div class=3D"cpp source-cpp"><pre class=3D"de1"><span class=
=3D"br0"><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250=
, 250); border-color: rgb(187, 187, 187); border-style: solid; border-width=
: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"su=
bprettyprint"><span style=3D"color: #606;" class=3D"styled-by-prettify">tem=
plate<class </span><code class=3D"prettyprint"><code class=3D"prettyprin=
t"><span class=3D"mw-geshi cpp source-cpp"><code class=3D"prettyprint"><spa=
n class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-prettify"><=
/span></span></code><code class=3D"prettyprint"><span class=3D"sy1"><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify"><code class=3D"prettypri=
nt"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"></span><span style=3D"color: #606;" class=3D"sty=
led-by-prettify">InputIt</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify"></span></span></code></span></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify"></span></code></span></code></code><span st=
yle=3D"color: #606;" class=3D"styled-by-prettify">, class A, class B><br=
>std::pair<</span><code class=3D"prettyprint"><code class=3D"prettyprint=
"><span class=3D"mw-geshi cpp source-cpp"><code class=3D"prettyprint"><span=
class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-prettify"></=
span></span></code><code class=3D"prettyprint"><span class=3D"sy1"><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify"><code class=3D"prettyprin=
t"><span class=3D"mw-geshi cpp source-cpp"><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"></span><span style=3D"color: #606;" class=3D"styl=
ed-by-prettify">InputIt</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify"></span></span></code></span></span><span style=3D"color: #660;=
" class=3D"styled-by-prettify"></span></code></span></code></code><span sty=
le=3D"color: #606;" class=3D"styled-by-prettify">, </span><code class=3D"pr=
ettyprint"><code class=3D"prettyprint"><span class=3D"mw-geshi cpp source-c=
pp"><code class=3D"prettyprint"><span class=3D"sy1"><span style=3D"color: #=
660;" class=3D"styled-by-prettify"></span></span></code><code class=3D"pret=
typrint"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-b=
y-prettify"><code class=3D"prettyprint"><span class=3D"mw-geshi cpp source-=
cpp"><span style=3D"color: #000;" class=3D"styled-by-prettify"></span><span=
style=3D"color: #606;" class=3D"styled-by-prettify">InputIt</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify"></span></span></code></sp=
an></span><span style=3D"color: #660;" class=3D"styled-by-prettify"></span>=
</code></span></code></code><span style=3D"color: #606;" class=3D"styled-by=
-prettify">> extract_between_if(</span><code class=3D"prettyprint"><code=
class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><code class=
=3D"prettyprint"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"=
styled-by-prettify"></span></span></code><code class=3D"prettyprint"><span =
class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-prettify"><co=
de class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"></span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">InputIt</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify"></span></span></code></span></span><span=
style=3D"color: #660;" class=3D"styled-by-prettify"> </span></code></span>=
</code></code><span style=3D"color: #606;" class=3D"styled-by-prettify"><co=
de class=3D"prettyprint"><code class=3D"prettyprint"><span class=3D"mw-gesh=
i cpp source-cpp"><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>first</span></span></code></code>, </span><code class=3D"prettyprint"><cod=
e class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><code class=
=3D"prettyprint"><span class=3D"sy1"><span style=3D"color: #660;" class=3D"=
styled-by-prettify"></span></span></code><code class=3D"prettyprint"><span =
class=3D"sy1"><span style=3D"color: #660;" class=3D"styled-by-prettify"><co=
de class=3D"prettyprint"><span class=3D"mw-geshi cpp source-cpp"><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"></span><span style=3D"color=
: #606;" class=3D"styled-by-prettify">InputIt</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify"></span></span></code></span></span><span=
style=3D"color: #660;" class=3D"styled-by-prettify"> </span></code></span>=
</code></code><span style=3D"color: #606;" class=3D"styled-by-prettify">las=
t, A begin_p, B const& end_p)<br>{<br> first =3D std::find_if(first,=
last, a);<br><br> if(first !=3D last)<br> ++first;<br><br> re=
turn {first, std::find_if(first, last, b)};<br>}</span><span style=3D"color=
: #606;" class=3D"styled-by-prettify"></span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify"></span></div></code></div><br><br></span></pre>=
</div></div>
</td></tr><tr><th><h3><span class=3D"mw-headline" id=3D"Example">Example</s=
pan></h3>
<div class=3D"t-example"><p> The following example finds a tag in a vector =
of char representing a list of tags.
</p><div class=3D"t-example-live-link"><div class=3D"coliru-btn coliru-btn=
-run-init">Run this code</div></div>
<div dir=3D"ltr" class=3D"mw-geshi t-example-code" style=3D"text-align: lef=
t;"><div class=3D"cpp source-cpp"><pre class=3D"de1"><div class=3D"prettypr=
int" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, =
187, 187); border-style: solid; border-width: 1px; word-wrap: break-word;">=
<code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"co=
lor: #800;" class=3D"styled-by-prettify">#include</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;"=
class=3D"styled-by-prettify"><iostream></span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #800;"=
class=3D"styled-by-prettify">#include</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"s=
tyled-by-prettify"><algorithm></span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" class=3D"=
styled-by-prettify">#include</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #080;" class=3D"styled-by-p=
rettify"><string></span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify"><br>int</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> main</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">()</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> std</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">vector</span><span styl=
e=3D"color: #080;" class=3D"styled-by-prettify"><int></span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> v </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">{</span><span style=3D"color: #066;" class=3D"sty=
led-by-prettify">1</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">2</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">5</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by=
-prettify">4</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #066;" class=3D"styled-by-prettify">6</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066=
;" class=3D"styled-by-prettify">2</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-pret=
tify">3</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #066;" class=3D"styled-by-prettify">4</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">};<br></span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br> </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> result1_pair_it </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify">extract</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">(</span><a href=3D"http://en.cppreference.com/w/cpp/itera=
tor/begin"><span style=3D"color: #000;" class=3D"styled-by-prettify">std</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">begin</span></a><span=
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify">v</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">),</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> </span><a href=3D"http://en.cppreference.com/w/=
cpp/iterator/end"><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">end</span></a>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">v</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">),</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">5</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">2</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br><br> std=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">vector result1</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">result1_pair_it</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">first</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> result1_pair_it</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">.</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">second</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br> </span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify"> for</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>auto</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> i </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">:</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> result1</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"><br> std</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">cout </span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify"><<</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> i </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify"><<</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">' '</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br><br> std</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify">cout </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify"><<</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> </span><span style=3D"color: #080;" class=3D"styled-by-prettify">'\n'</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br><br> </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> result2_pair_it </s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">extract_between</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><a href=3D"http://en=
..cppreference.com/w/cpp/iterator/begin"><span style=3D"color: #000;" class=
=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">::</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">begin</span></a><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">v=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">),</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><a href=3D=
"http://en.cppreference.com/w/cpp/iterator/end"><span style=3D"color: #000;=
" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">end</span></a><span style=3D"color: #660;" class=3D"styled-=
by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">v</span><span style=3D"color: #660;" class=3D"styled-by-prettify">),</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #066;" class=3D"styled-by-prettify">5</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" cla=
ss=3D"styled-by-prettify">2</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br><br> std</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">vector result2</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">result2_pair_it</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">first</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> result2_pai=
r_it</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify">second</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">for</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> i </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">:</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> result2</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r> std</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
cout </span><span style=3D"color: #660;" class=3D"styled-by-prettify"><&=
lt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> i </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify"><<</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #080;" class=3D"styled-by-prettify">' '</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br><br> std</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify">cout </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #080;" class=3D"=
styled-by-prettify">'\n'</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"><br><br> </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> result3_pair_it </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">extract_=
between_if</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><a href=3D"http://en.cppreference.com/w/cpp/iterator/begin"><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify">std</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"color: =
#008;" class=3D"styled-by-prettify">begin</span></a><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">v</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">),</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><a href=3D"http://en.cppreference.com/w/cpp/iterator/end">=
<span style=3D"color: #000;" class=3D"styled-by-prettify">std</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">end</span></a><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">v</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">),</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">[](</span><spa=
n style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> i</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">){</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> i </span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">></span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">5<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">},</span><span style=3D"colo=
r: #660;" class=3D"styled-by-prettify"><br> =
[](</span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> i</span><span style=3D"color: #660;" class=3D"styled-by-prettify">){<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">return</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> i </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">></span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" =
class=3D"styled-by-prettify">10</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">});</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
<br> std</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">ve=
ctor result3</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">result3=
_pair_it</span><span style=3D"color: #660;" class=3D"styled-by-prettify">.<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">first</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> result3_pair_it</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">second</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">for</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"sty=
led-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> i </span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">:</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> resu=
lt3</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify">cout </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify"><<</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> i </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify"><<</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #080;" class=3D"styled-by-prettify">' '</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">}</span></div></code></div><span class=3D"br0"><br></span=
></pre></div></div>
<p>Output:
</p>
<div dir=3D"ltr" class=3D"mw-geshi" style=3D"text-align: left;"><div class=
=3D"text source-text"><pre class=3D"de1">5 4 6 2=20
4 6 <br>2 3 4<br></pre></div></div>=20
</div></th></tr><tr><td><br></td></tr></tbody></table></th></tr><tr><td><br=
>I hope you understand the utility of this algorithm. Using it on string is=
frequent too... saves up a lot of substr and find...<br>As i heard the com=
mittee wants new algorithms, what would you recommand=20
about this algorithm ? Is there already a proposal for such an algorithm
? Is there any modification to be made on it so that it fits better to=20
the STL ?<br><br>Thanks for reading at least.<br><br>germinolegrand<br></td=
></tr>
</tbody></table><p>
</p></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_884_14318831.1393194365974--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Mon, 24 Feb 2014 07:44:43 +0200
Raw View
On 24 February 2014 00:26, <germinolegrand@gmail.com> wrote:
> auto result3_pair_it = std::extract_between_if(std::begin(v), std::end(v),
> [](int i){ return i > 5; },
> [](int i){ return i > 10; });
>
> std::vector result3(result3_pair_it.first, result3_pair_it.second);
> for(auto i : result3)
> std::cout << i << ' ';
> }
>
> Output:
>
> 5 4 6 2
> 4 6
> 2 3 4
>
>
>
>
> I hope you understand the utility of this algorithm. Using it on string is frequent too... saves up a lot of substr and find...
> As i heard the committee wants new algorithms, what would you recommand about this algorithm ? Is there already a proposal for such an algorithm ? Is there any modification to be made on it so that it fits better to the STL ?
>
> Thanks for reading at least.
Looks useful to me. I find it curious that the last example returns
from first to end,
since the first predicate matched but the second predicate didn't
match. Maybe that's just me.
Anyway, I think this is certainly something SG9 (Ranges) should take a look at.
And yes, I've written such things by hand many times, and cursed not
having it in the standard.
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.
Author: germinolegrand@gmail.com
Date: Mon, 24 Feb 2014 16:59:02 -0800 (PST)
Raw View
------=_Part_1296_27582540.1393289942363
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
It matters to find the first delimiter. For the second delimiter, you try=
=20
to find it, but if you don't find it, it's because you reached the end of=
=20
the range, you can't go further. But since you found the beginning of the=
=20
extract, you want everything next, until you find a delimiter, either a=20
specific value or an end-of-range.
It's more obvious when you have to parse something like that :=20
"!tag:fruit!tag:yellow!word:banana" you want to get the "banana", something=
=20
being after or not. Plus, you can check if it really matters to you if the=
=20
result end equals to the input last, i see no real alternative that permits=
=20
both checking if you absolutely want the two delimiters and having the=20
result nevertheless.
For the range in the form of a std::pair<iterator, iterator>, i just took a=
=20
look =C3=A0 std::equal_range.
I'm glad you find this useful.
germinolegrand
Le lundi 24 f=C3=A9vrier 2014 06:44:43 UTC+1, Ville Voutilainen a =C3=A9cri=
t :
>
> On 24 February 2014 00:26, <germino...@gmail.com <javascript:>> wrote:=20
> > auto result3_pair_it =3D std::extract_between_if(std::begin(v),=20
> std::end(v),=20
> > [](int i){ return i =
>=20
> 5; },=20
> > [](int i){ return i =
>=20
> 10; });=20
> >=20
> > std::vector result3(result3_pair_it.first, result3_pair_it.second);=
=20
> > for(auto i : result3)=20
> > std::cout << i << ' ';=20
> > }=20
> >=20
> > Output:=20
> >=20
> > 5 4 6 2=20
> > 4 6=20
> > 2 3 4=20
> >=20
> >=20
> >=20
> >=20
> > I hope you understand the utility of this algorithm. Using it on string=
=20
> is frequent too... saves up a lot of substr and find...=20
> > As i heard the committee wants new algorithms, what would you recommand=
=20
> about this algorithm ? Is there already a proposal for such an algorithm =
?=20
> Is there any modification to be made on it so that it fits better to the=
=20
> STL ?=20
> >=20
> > Thanks for reading at least.=20
>
>
> Looks useful to me. I find it curious that the last example returns=20
> from first to end,=20
> since the first predicate matched but the second predicate didn't=20
> match. Maybe that's just me.=20
> Anyway, I think this is certainly something SG9 (Ranges) should take a=20
> look at.=20
> And yes, I've written such things by hand many times, and cursed not=20
> having it in the standard.=20
>
--=20
---=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_1296_27582540.1393289942363
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">It matters to find the first delimiter. For the second del=
imiter, you try to find it, but if you don't find it, it's because you reac=
hed the end of the range, you can't go further. But since you found the beg=
inning of the extract, you want everything next, until you find a delimiter=
, either a specific value or an end-of-range.<br>It's more obvious when you=
have to parse something like that : "!tag:fruit!tag:yellow!word:banana" yo=
u want to get the "banana", something being after or not. Plus, you can che=
ck if it really matters to you if the result end equals to the input last, =
i see no real alternative that permits both checking if you absolutely want=
the two delimiters and having the result nevertheless.<br><br>For the rang=
e in the form of a std::pair<iterator, iterator>, i just took a look =
=C3=A0 std::equal_range.<br><br>I'm glad you find this useful.<br><br>germi=
nolegrand<br><br>Le lundi 24 f=C3=A9vrier 2014 06:44:43 UTC+1, Ville Voutil=
ainen a =C3=A9crit :<blockquote class=3D"gmail_quote" style=3D"margin:=
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 24=
February 2014 00:26, <<a href=3D"javascript:" target=3D"_blank" gdf-obf=
uscated-mailto=3D"-J52uS-kLXQJ" onmousedown=3D"this.href=3D'javascript:';re=
turn true;" onclick=3D"this.href=3D'javascript:';return true;">germino...@g=
mail.com</a>> wrote:
<br>> auto result3_pair_it =3D std::extract_between_if(std=
::<wbr>begin(v), std::end(v),
<br>> &nb=
sp; &=
nbsp; [](int i){ return i > 5; },
<br>> &nb=
sp; &=
nbsp; [](int i){ return i > 10; });
<br>>
<br>> std::vector result3(result3_pair_it.first, result3_p=
air_it.second);
<br>> for(auto i : result3)
<br>> std::cout << i << ' ';
<br>> }
<br>>
<br>> Output:
<br>>
<br>> 5 4 6 2
<br>> 4 6
<br>> 2 3 4
<br>>
<br>>
<br>>
<br>>
<br>> I hope you understand the utility of this algorithm. Using it on s=
tring is frequent too... saves up a lot of substr and find...
<br>> As i heard the committee wants new algorithms, what would you reco=
mmand about this algorithm ? Is there already a proposal for such an algori=
thm ? Is there any modification to be made on it so that it fits better to =
the STL ?
<br>>
<br>> Thanks for reading at least.
<br>
<br>
<br>Looks useful to me. I find it curious that the last example returns
<br>from first to end,
<br>since the first predicate matched but the second predicate didn't
<br>match. Maybe that's just me.
<br>Anyway, I think this is certainly something SG9 (Ranges) should take a =
look at.
<br>And yes, I've written such things by hand many times, and cursed not
<br>having it in the standard.
<br></blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_1296_27582540.1393289942363--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Tue, 25 Feb 2014 07:56:56 +0200
Raw View
On 25 February 2014 02:59, <germinolegrand@gmail.com> wrote:
> It matters to find the first delimiter. For the second delimiter, you try=
to
> find it, but if you don't find it, it's because you reached the end of th=
e
> range, you can't go further. But since you found the beginning of the
> extract, you want everything next, until you find a delimiter, either a
> specific value or an end-of-range.
> It's more obvious when you have to parse something like that :
> "!tag:fruit!tag:yellow!word:banana" you want to get the "banana", somethi=
ng
> being after or not. Plus, you can check if it really matters to you if th=
e
> result end equals to the input last, i see no real alternative that permi=
ts
> both checking if you absolutely want the two delimiters and having the
> result nevertheless.
Fair enough, seems reasonable, thanks for the explanation.
> For the range in the form of a std::pair<iterator, iterator>, i just took=
a
> look =E0 std::equal_range.
That seems ok to me.
> I'm glad you find this useful.
Please convey this proposal to the committee. This link should
provide useful instructions http://isocpp.org/std/submit-a-proposal
--=20
---=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
.
Author: Philipp Maximilian Stephani <p.stephani2@gmail.com>
Date: Tue, 25 Feb 2014 19:09:35 +0000
Raw View
--20cf307d021038d86504f33fd4bc
Content-Type: text/plain; charset=UTF-8
I think these are useful additions. However, the iterators should be
forward iterators, as "first" could be invalidated before return if it's
only an input iterator.
On Sun Feb 23 2014 at 23:26:07, <germinolegrand@gmail.com> wrote:
> Hello,
>
> Here is an algorithm i often need, and often use because it amazingly
> simplifies the code readability, and suppresses hours of debugging
> headaches.
>
> If i had to write a cppreference entry about it, it would look like that :
>
> *std::extract, std::extract_if, std::extract_between,
> std::extract_between_if*
>
> template< class InputIt, class A, class B >
>
> std::pair <http://en.cppreference.com/w/cpp/utility/pair><InputIt,InputIt>
> extract(InputIt first, InputIt last, A const& begin_value, B const&end_value
> ); (1)
>
> template< class InputIt, class UnaryPredicateA, class UnaryPredicateB >
>
> std::pair <http://en.cppreference.com/w/cpp/utility/pair><InputIt,InputIt>
> extract_if(InputIt first, InputIt last, UnaryPredicateA begin_p,
> UnaryPredicateB end_p); (2)
>
>
> template< class InputIt, class A, class B >
>
> std::pair <http://en.cppreference.com/w/cpp/utility/pair><InputIt,InputIt>
> extract_between(InputIt first, InputIt last, A const& begin_value, B
> const& end_value); (3)
>
> template< class InputIt, class UnaryPredicateA, class UnaryPredicateB >
> std::pair <http://en.cppreference.com/w/cpp/utility/pair><InputIt,InputIt>
> extract_between_if(InputIt first, InputIt last, UnaryPredicateAbegin_p
> , UnaryPredicateB end_p); (4)
>
> Returns the first range in the range [first, last) that satisfies
> specific criteria:
>
> 1) the first element is equal to begin_value, and except the first
> element only the last element may be equal to end_value
>
> 2) the first element is an element for which predicate begin_p returns
> true, and except the first element only the last element may be an
> element for which predicate p returns true
>
> 3) the element before the first element is equal to begin_value, and
> except the element before the first element only the element after the last
> element may be equal to end_value
>
> 4) the element before the first element is an element for which predicate
> begin_p returns true, and except the element before the first element
> only the element after the last element may be an element for which
> predicate p returns true
> Parameters first, last - the range of elements to examine begin_value,
> end_value - values to compare the elements to begin_p, end_p - unary
> predicates which return true for the required element.
>
> The signature of the predicate functions should be equivalent to the
> following:
>
> bool pred(const Type &a);
>
> The signature does not need to have const &, but the functions must not
> modify the objects passed to it.
> The type Type must be such that an object of type InputIt can be
> dereferenced and then implicitly converted to Type.
> Type requirements -InputIt must meet the requirements of InputIterator<http://en.cppreference.com/w/cpp/concept/InputIterator>.
> -UnaryPredicate must meet the requirements of Predicate<http://en.cppreference.com/w/cpp/concept/Predicate>.
>
>
> Return value
>
> std::pair <http://en.cppreference.com/w/cpp/utility/pair> containing a
> pair of iterators defining the wanted range, the first pointing to the
> first element satisfying the condition ((1) (2)) or the element after the
> first element satisfying the condition and the second pointing to the first
> element *greater* than value.
>
> If there are no elements satisfying the condition for the first, last is
> returned as the first element. Similarly if there are no elements
> satisfying the condition for the second, last is returned as the second
> element.
> Complexity
>
> At most last - first applications of one of the two predicats.
> Possible implementation First version
>
> template<class InputIt, class A, class B>
> std::pair<InputIt, InputIt> extract(InputIt first, InputIt last, A const& begin_value, B const& end_value)
> {
> first = std::find(first, last, begin_value);
>
> InputIt sub_last = std::find(first, last, end_value);
>
> if(sub_last != last)
> ++sub_last;
>
> return {first, sub_last};
> }
>
>
> Second version
>
> template<class InputIt, class A, class B>
> std::pair<InputIt, InputIt> extract_if(InputIt first, InputIt last, A begin_p, B end_p)
> {
> first = std::find_if(first, last, begin_p);
>
> InputIt sub_last = std::find_if(first, last, end_p);
>
> if(sub_last != last)
> ++sub_last;
>
> return {first, sub_last};
> }
>
>
> Third version
>
> template<class InputIt, class A, class B>
> std::pair<InputIt, InputIt> extract_between(InputIt first, InputIt last, A const& begin_value, B const& end_value)
> {
> first = std::find(first, last, a);
>
> if(first != last)
> ++first;
>
> return {first, std::find(first, last, b)};
> }
>
> Fourth version
>
> template<class InputIt, class A, class B>
> std::pair<InputIt, InputIt> extract_between_if(InputIt first, InputIt last, A begin_p, B const& end_p)
> {
> first = std::find_if(first, last, a);
>
> if(first != last)
> ++first;
>
> return {first, std::find_if(first, last, b)};
> }
>
>
> Example
>
> The following example finds a tag in a vector of char representing a list
> of tags.
> Run this code
>
> #include <iostream>
> #include <algorithm>
> #include <string>
>
> int main()
> {
> std::vector<int> v = {1, 2, 5, 4, 6, 2, 3, 4};
>
> auto result1_pair_it = std::extract(std::begin <http://en.cppreference.com/w/cpp/iterator/begin>(v), std::end <http://en.cppreference.com/w/cpp/iterator/end>(v), 5, 2);
>
> std::vector result1(result1_pair_it.first, result1_pair_it.second);
> for(auto i : result1)
> std::cout << i << ' ';
>
> std::cout << '\n';
>
> auto result2_pair_it = std::extract_between(std::begin <http://en.cppreference.com/w/cpp/iterator/begin>(v), std::end <http://en.cppreference.com/w/cpp/iterator/end>(v), 5, 2);
>
> std::vector result2(result2_pair_it.first, result2_pair_it.second);
> for(auto i : result2)
> std::cout << i << ' ';
>
> std::cout << '\n';
>
> auto result3_pair_it = std::extract_between_if(std::begin <http://en.cppreference.com/w/cpp/iterator/begin>(v), std::end <http://en.cppreference.com/w/cpp/iterator/end>(v),
> [](int i){ return i > 5; },
> [](int i){ return i > 10; });
>
> std::vector result3(result3_pair_it.first, result3_pair_it.second);
> for(auto i : result3)
> std::cout << i << ' ';
> }
>
> Output:
>
> 5 4 6 2
> 4 6
> 2 3 4
>
>
>
> I hope you understand the utility of this algorithm. Using it on string is
> frequent too... saves up a lot of substr and find...
> As i heard the committee wants new algorithms, what would you recommand
> about this algorithm ? Is there already a proposal for such an algorithm ?
> Is there any modification to be made on it so that it fits better to the
> STL ?
>
> Thanks for reading at least.
>
> germinolegrand
>
> --
>
> ---
> 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.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>
--
---
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
--20cf307d021038d86504f33fd4bc
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
I think these are useful additions. However, the iterators should be forwar=
d iterators, as "first" could be invalidated before return if it&=
#39;s only an input iterator.<br><br><div>On Sun Feb 23 2014 at 23:26:07, &=
lt;<a href=3D"mailto:germinolegrand@gmail.com">germinolegrand@gmail.com</a>=
> wrote:</div>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr">Hello,<br><br>Here is an al=
gorithm i often need, and often use because it amazingly simplifies the cod=
e readability, and suppresses hours of debugging headaches.<br>
<br>If i had to write a cppreference entry about it, it would look like tha=
t :<br><br><font size=3D"4"><b>std::extract, std::extract_if, std::extract_=
between, std::extract_between_if</b></font><br><div style=3D"background-col=
or:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border=
-width:1px;word-wrap:break-word">
<code><div><br><div><span><span><span style=3D"color:#008">template</span><=
/span><span><span style=3D"color:#660"><</span></span><span style=3D"col=
or:#000"> </span><span><span style=3D"color:#008">class</span></span><span =
style=3D"color:#000"> </span><span style=3D"color:#606">InputIt</span><span=
style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span><spa=
n style=3D"color:#008">class</span></span><span style=3D"color:#000"> A</sp=
an><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#008">class</span><span style=3D"color:#000"> B </span><=
span><span style=3D"color:#660">></span></span><span style=3D"color:#000=
"><br>
</span><p><a href=3D"http://en.cppreference.com/w/cpp/utility/pair" target=
=3D"_blank"><span><span style=3D"color:#000">std</span><span style=3D"color=
:#660">::</span><span><span style=3D"color:#000">pair</span></span></span><=
/a><span><span style=3D"color:#660"><</span></span><code><span><span sty=
le=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><span sty=
le=3D"color:#660"></span></span></code><span style=3D"color:#660">,</span><=
code><span><span style=3D"color:#000"></span><span style=3D"color:#606">Inp=
utIt</span><span style=3D"color:#660"></span></span></code><span><span styl=
e=3D"color:#660">></span></span><span style=3D"color:#000"> <br>
=C2=A0 =C2=A0 ex</span><span><span style=3D"color:#000">tract</span><span s=
tyle=3D"color:#660">(</span></span><code><span><span style=3D"color:#000"><=
/span><span style=3D"color:#606">InputIt</span><span style=3D"color:#660"> =
</span></span></code><span style=3D"color:#000">first</span><span style=3D"=
color:#660">,</span><span style=3D"color:#000"> </span><code><span><span st=
yle=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><span st=
yle=3D"color:#660"> </span></span></code><span style=3D"color:#008">last</s=
pan><span style=3D"color:#660">,</span><span><span style=3D"color:#000"> A =
</span><span style=3D"color:#008">const</span></span><span><span style=3D"c=
olor:#660">&</span></span><span style=3D"color:#000"> begin_value</span=
><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><spa=
n><span style=3D"color:#000">B </span><span style=3D"color:#008">const</spa=
n><span style=3D"color:#660">&</span><span style=3D"color:#000"> end_va=
lue</span><span style=3D"color:#660">)</span></span><span><span style=3D"co=
lor:#660">;</span><span style=3D"color:#000"> (1)<br>
</span><span style=3D"color:#000"></span></span><br><code><span><span><span=
style=3D"color:#008">template</span></span><span><span style=3D"color:#660=
"><</span></span><span style=3D"color:#000"> </span><span><span style=3D=
"color:#008">class</span></span><span style=3D"color:#000"> </span></span><=
/code><code><span><span style=3D"color:#000"><code><span><span style=3D"col=
or:#000"></span><span style=3D"color:#606">InputIt</span><span style=3D"col=
or:#660"></span></span></code></span><span style=3D"color:#660">,</span><sp=
an style=3D"color:#000"> </span><span><span style=3D"color:#008">class</spa=
n></span><span style=3D"color:#000"> </span></span></code><code><span><span=
style=3D"color:#000"><span>UnaryPredicateA</span></span><span style=3D"col=
or:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#0=
08">class</span><span style=3D"color:#000"> </span></span></code><code><spa=
n><span style=3D"color:#000"><span>UnaryPredicate</span>B </span><span><spa=
n style=3D"color:#660">></span></span><span style=3D"color:#000"><br>
</span></span></code></p><p><code><a href=3D"http://en.cppreference.com/w/c=
pp/utility/pair" target=3D"_blank"><span><span style=3D"color:#000">std</sp=
an><span style=3D"color:#660">::</span><span><span style=3D"color:#000">pai=
r</span></span></span></a><span><span style=3D"color:#660"><</span></spa=
n><code><span><span style=3D"color:#000"></span><span style=3D"color:#606">=
InputIt</span><span style=3D"color:#660"></span></span></code><span style=
=3D"color:#660">,</span><code><span><span style=3D"color:#000"></span><span=
style=3D"color:#606">InputIt</span><span style=3D"color:#660"></span></spa=
n></code><span><span style=3D"color:#660">></span></span><span style=3D"=
color:#000"> <br>
=C2=A0 =C2=A0 ex</span><span><span style=3D"color:#000">tract</span><span s=
tyle=3D"color:#660">_if(</span></span><code><span><span style=3D"color:#000=
"></span><span style=3D"color:#606">InputIt</span><span style=3D"color:#660=
"> </span></span></code><span style=3D"color:#000">first</span><span style=
=3D"color:#660">,</span><span style=3D"color:#000"> </span><code><span><spa=
n style=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><spa=
n style=3D"color:#660"> </span></span></code><span style=3D"color:#008">las=
t</span><span style=3D"color:#660">,</span><span><span style=3D"color:#000"=
> </span></span><span><span style=3D"color:#000"><span>UnaryPredicate</span=
>A</span></span><span style=3D"color:#000"> begin_p</span><span style=3D"co=
lor:#660">,</span><span style=3D"color:#000"> </span><span>UnaryPredicate</=
span><span><span style=3D"color:#000">B</span><span style=3D"color:#000"> e=
nd_p</span><span style=3D"color:#660">)</span></span><span><span style=3D"c=
olor:#660">; (2)<br>
</span></span></code></p></span><p></p><span style=3D"color:#000"></span><b=
r><code><span><span><span style=3D"color:#008">template</span></span><span>=
<span style=3D"color:#660"><</span></span><span style=3D"color:#000"> </=
span><span><span style=3D"color:#008">class</span></span><span style=3D"col=
or:#000"> </span></span></code><code><span><span style=3D"color:#000"><code=
><span><span style=3D"color:#000"></span><span style=3D"color:#606">InputIt=
</span><span style=3D"color:#660"></span></span></code></span><span style=
=3D"color:#660">,</span><span style=3D"color:#000"> </span><span><span styl=
e=3D"color:#008">class</span></span><span style=3D"color:#000"> A</span><sp=
an style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span st=
yle=3D"color:#008">class</span><span style=3D"color:#000"> B </span><span><=
span style=3D"color:#660">></span></span><span style=3D"color:#000"><br>
</span><p><a href=3D"http://en.cppreference.com/w/cpp/utility/pair" target=
=3D"_blank"><span><span style=3D"color:#000">std</span><span style=3D"color=
:#660">::</span><span><span style=3D"color:#000">pair</span></span></span><=
/a><span><span style=3D"color:#660"><</span></span><code><span><span sty=
le=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><span sty=
le=3D"color:#660"></span></span></code><span style=3D"color:#660">,</span><=
code><span><span style=3D"color:#000"></span><span style=3D"color:#606">Inp=
utIt</span><span style=3D"color:#660"></span></span></code><span><span styl=
e=3D"color:#660">></span></span><span style=3D"color:#000"> <br>
=C2=A0 =C2=A0 ex</span><span><span style=3D"color:#000">tract_between</span=
><span style=3D"color:#660">(</span></span><code><span><span style=3D"color=
:#000"></span><span style=3D"color:#606">InputIt</span><span style=3D"color=
:#660"> </span></span></code><span style=3D"color:#000">first</span><span s=
tyle=3D"color:#660">,</span><span style=3D"color:#000"> </span><code><span>=
<span style=3D"color:#000"></span><span style=3D"color:#606">InputIt</span>=
<span style=3D"color:#660"> </span></span></code><span style=3D"color:#008"=
>last</span><span style=3D"color:#660">,</span><span><span style=3D"color:#=
000"> A </span><span style=3D"color:#008">const</span></span><span><span st=
yle=3D"color:#660">&</span></span><span style=3D"color:#000"> begin_val=
ue</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </s=
pan><span><span style=3D"color:#000">B </span><span style=3D"color:#008">co=
nst</span><span style=3D"color:#660">&</span><span style=3D"color:#000"=
> end_value</span><span style=3D"color:#660">)</span></span><span><span sty=
le=3D"color:#660">;</span><span style=3D"color:#000"> (3)<br>
</span><span style=3D"color:#000"></span></span><br><code><span><span><span=
style=3D"color:#008">template</span></span><span><span style=3D"color:#660=
"><</span></span><span style=3D"color:#000"> </span><span><span style=3D=
"color:#008">class</span></span><span style=3D"color:#000"> </span></span><=
/code><code><span><span style=3D"color:#000"><code><span><span style=3D"col=
or:#000"></span><span style=3D"color:#606">InputIt</span><span style=3D"col=
or:#660"></span></span></code></span><span style=3D"color:#660">,</span><sp=
an style=3D"color:#000"> </span><span><span style=3D"color:#008">class</spa=
n></span><span style=3D"color:#000"> </span></span></code><code><span><span=
style=3D"color:#000"><span>UnaryPredicateA</span></span><span style=3D"col=
or:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#0=
08">class</span><span style=3D"color:#000"> </span></span></code><code><spa=
n><span style=3D"color:#000"><span>UnaryPredicate</span>B </span><span><spa=
n style=3D"color:#660">></span></span><span style=3D"color:#000"></span>=
</span><a href=3D"http://en.cppreference.com/w/cpp/utility/pair" target=3D"=
_blank"><span><span style=3D"color:#000"><br>
std</span><span style=3D"color:#660">::</span><span><span style=3D"color:#0=
00">pair</span></span></span></a><span><span style=3D"color:#660"><</spa=
n></span></code><code><span><span style=3D"color:#660"><code><span><span st=
yle=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><span st=
yle=3D"color:#660"></span></span></code></span></span><span style=3D"color:=
#660">,</span></code><code><span style=3D"color:#660"><code><span><span sty=
le=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><span sty=
le=3D"color:#660"></span></span></code></span><span><span style=3D"color:#6=
60">></span></span><span style=3D"color:#000"> <br>
=C2=A0 =C2=A0 ex</span><span><span style=3D"color:#000">tract_</span><span =
style=3D"color:#660">between_if(</span></span></code><code><span><span styl=
e=3D"color:#660"><code><span><span style=3D"color:#000"></span><span style=
=3D"color:#606">InputIt</span><span style=3D"color:#660"> </span></span></c=
ode></span></span><span style=3D"color:#000">first</span><span style=3D"col=
or:#660">,</span><span style=3D"color:#000"> </span></code><code><span styl=
e=3D"color:#000"><code><span><span style=3D"color:#000"></span><span style=
=3D"color:#606">InputIt</span><span style=3D"color:#660"> </span></span></c=
ode></span><span style=3D"color:#008">last</span><span style=3D"color:#660"=
>,</span><span><span style=3D"color:#000"> </span></span><span><span style=
=3D"color:#000"><span>UnaryPredicate</span>A</span></span><span style=3D"co=
lor:#000"> begin_p</span><span style=3D"color:#660">,</span><span style=3D"=
color:#000"> </span><span>UnaryPredicate</span><span><span style=3D"color:#=
000">B</span><span style=3D"color:#000"> end_p</span><span style=3D"color:#=
660">)</span></span><span><span style=3D"color:#660">; (4)<br>
</span></span></code></p></span></code></div></div></code></div>
<p>Returns the first range in the range <code>[first, last)</code> that sat=
isfies specific criteria:</p><p>1) the first element is equal to <code><spa=
n><span style=3D"color:#000">begin_value</span></span></code>, and except t=
he first element only the last element may be equal to <code><span><span><s=
pan style=3D"color:#000">end_value</span></span></span></code><br>
</p><p>2) the first element is an element for which predicate <code>begin_p=
</code> returns <span><span><span>true</span></span></span>, and except the=
first element only the last element may be an element for which predicate =
<code>p</code> returns <span><span><span>true</span></span></span><br>
</p><p>3) the element before the first element is equal to <code><span><spa=
n style=3D"color:#000">begin_value</span></span></code>, and except the ele=
ment before the first element only the element after the last element may b=
e equal to <code><span><span><span style=3D"color:#000">end_value</span></s=
pan></span></code><br>
</p><p>4) the element before the first element is an element for which pred=
icate <code>begin_p</code> returns <span><span><span>true</span></span></sp=
an>, and except the element before the first element only the element after=
the last element may be an element for which predicate <code>p</code> retu=
rns <span><span><span>true</span></span></span></p>
<h3><span>Parameters</span></h3>
<table>
<tbody><tr>
<td> first, last
</td>
<td> -
</td>
<td> the range of elements to examine
</td></tr>
<tr>
<td> begin_value, end_value
</td>
<td> -
</td>
<td> values to compare the elements to
</td></tr>
<tr>
<td> begin_p, end_p
</td>
<td> -
</td>
<td>unary predicates which return <span><span><span>true</span></span></spa=
n> for the required element. <br>
<p>The signature of the predicate functions should be equivalent to the fol=
lowing:
</p><p><span><span>=C2=A0<span>bool</span> pred<span>(</span><span>const</s=
pan> Type <span>&</span>a<span>)</span><span>;</span></span></span>
</p><p>The signature does not need to have <span><span><span>const</span> <=
span>&</span></span></span>, but the functions must not modify the obje=
cts passed to it.<br>
The type <span><span>Type</span></span> must be such that an object of type=
<span><span>InputIt</span></span> can be dereferenced and then implicitly =
converted to <span><span>Type</span></span>.
</p></td></tr>
<tr>
<td colspan=3D"3"><table><tbody><tr><td colspan=3D"3">Type requirements
</td></tr>
<tr>
<td colspan=3D"3"> -<code>InputIt</code> must meet the requirements of <a h=
ref=3D"http://en.cppreference.com/w/cpp/concept/InputIterator" title=3D"cpp=
/concept/InputIterator" target=3D"_blank"><code>InputIterator</code></a>.
</td></tr>
<tr>
<td colspan=3D"3"> -<code>UnaryPredicate</code> must meet the requirements =
of <a href=3D"http://en.cppreference.com/w/cpp/concept/Predicate" title=3D"=
cpp/concept/Predicate" target=3D"_blank"><code>Predicate</code></a>.
</td></tr></tbody></table></td></tr>
<tr>
<td colspan=3D"3"><br></td></tr></tbody></table><h3><br><span></span></h3><=
h3><span>Return value</span></h3>
<p><span><a href=3D"http://en.cppreference.com/w/cpp/utility/pair" title=3D=
"cpp/utility/pair" target=3D"_blank">std::pair</a></span> containing a pair=
of iterators defining the wanted range, the first pointing to the first el=
ement satisfying the condition ((1) (2)) or the element after<code></code>=
the first element satisfying the condition and the second pointing to the =
first element <i>greater</i> than <code>value</code>.=20
</p><p>If there are no elements satisfying the condition for the first<code=
></code><i><code></code></i><code></code>, <code>last</code> is returned as=
the first element. Similarly if there are no elements satisfying the condi=
tion for the second<code></code>, <code>last</code> is returned as the seco=
nd element.</p>
<h3><span>Complexity</span></h3>
<p>At most <code>last</code> - <code>first</code> applications of one of th=
e two predicats. <br></p><h3><span>Possible implementation</span></h3>
<table>
<tbody><tr>
<th> First version</th></tr><tr><td><div dir=3D"ltr" style=3D"text-align:le=
ft"><div><pre><span><div style=3D"background-color:rgb(250,250,250);border-=
color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-=
word">
<code><div><span style=3D"color:#606">template<class </span><code><code>=
<span><code><span><span style=3D"color:#660"></span></span></code><code><sp=
an><span style=3D"color:#660"><code><span><span style=3D"color:#000"></span=
><span style=3D"color:#606">InputIt</span><span style=3D"color:#660"></span=
></span></code></span></span><span style=3D"color:#660"></span></code></spa=
n></code></code><span style=3D"color:#606">, class A, class B><br>
std::pair<</span><code><code><span><code><span><span style=3D"color:#660=
"></span></span></code><code><span><span style=3D"color:#660"><code><span><=
span style=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><=
span style=3D"color:#660"></span></span></code></span></span><span style=3D=
"color:#660"></span></code></span></code></code><span style=3D"color:#606">=
, </span><code><code><span><code><span><span style=3D"color:#660"></span></=
span></code><code><span><span style=3D"color:#660"><code><span><span style=
=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><span style=
=3D"color:#660"></span></span></code></span></span><span style=3D"color:#66=
0"></span></code></span></code></code><span style=3D"color:#606">> extra=
ct(</span><code><code><span><code><span><span style=3D"color:#660"></span><=
/span></code><code><span><span style=3D"color:#660"><code><span><span style=
=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><span style=
=3D"color:#660"></span></span></code></span></span><span style=3D"color:#66=
0"> </span></code></span></code></code><span style=3D"color:#606"><code><co=
de><span><span style=3D"color:#660">first</span></span></code></code>, </sp=
an><code><code><span><code><span><span style=3D"color:#660"></span></span><=
/code><code><span><span style=3D"color:#660"><code><span><span style=3D"col=
or:#000"></span><span style=3D"color:#606">InputIt</span><span style=3D"col=
or:#660"></span></span></code></span></span><span style=3D"color:#660"> </s=
pan></code></span></code></code><span style=3D"color:#606">last, A const&am=
p; begin_value, B const& end_value)<br>
{<br> first =3D std::find(first, last, begin_value);<br><br> </span><=
code><code><span><code><span><span style=3D"color:#660"></span></span></cod=
e><code><span><span style=3D"color:#660"><code><span><span style=3D"color:#=
000"></span><span style=3D"color:#606">InputIt</span><span style=3D"color:#=
660"></span></span></code></span></span><span style=3D"color:#660"> </span>=
</code></span></code></code><span style=3D"color:#606">sub_last =3D std::fi=
nd(first, last, end_value);<br>
<br> if(sub_last !=3D last)<br> ++sub_last;<br><br> return {fi=
rst, sub_last};<br>}</span><span style=3D"color:#660"></span></div></code><=
/div><br><br></span></pre></div></div>
</td></tr>
<tr>
<th> Second version</th></tr><tr><td><div dir=3D"ltr" style=3D"text-align:l=
eft"><div><pre><span><div style=3D"background-color:rgb(250,250,250);border=
-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break=
-word">
<code><div><span style=3D"color:#606">template<class </span><code><code>=
<span><code><span><span style=3D"color:#660"></span></span></code><code><sp=
an><span style=3D"color:#660"><code><span><span style=3D"color:#000"></span=
><span style=3D"color:#606">InputIt</span><span style=3D"color:#660"></span=
></span></code></span></span><span style=3D"color:#660"></span></code></spa=
n></code></code><span style=3D"color:#606">, class A, class B><br>
std::pair<</span><code><code><span><code><span><span style=3D"color:#660=
"></span></span></code><code><span><span style=3D"color:#660"><code><span><=
span style=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><=
span style=3D"color:#660"></span></span></code></span></span><span style=3D=
"color:#660"></span></code></span></code></code><span style=3D"color:#606">=
, </span><code><code><span><code><span><span style=3D"color:#660"></span></=
span></code><code><span><span style=3D"color:#660"><code><span><span style=
=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><span style=
=3D"color:#660"></span></span></code></span></span><span style=3D"color:#66=
0"></span></code></span></code></code><span style=3D"color:#606">> extra=
ct_if(</span><code><code><span><code><span><span style=3D"color:#660"></spa=
n></span></code><code><span><span style=3D"color:#660"><code><span><span st=
yle=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><span st=
yle=3D"color:#660"></span></span></code></span></span><span style=3D"color:=
#660"> </span></code></span></code></code><span style=3D"color:#606"><code>=
<code><span><span style=3D"color:#660">first</span></span></code></code>, <=
/span><code><code><span><code><span><span style=3D"color:#660"></span></spa=
n></code><code><span><span style=3D"color:#660"><code><span><span style=3D"=
color:#000"></span><span style=3D"color:#606">InputIt</span><span style=3D"=
color:#660"></span></span></code></span></span><span style=3D"color:#660"> =
</span></code></span></code></code><span style=3D"color:#606">last, A begin=
_p, B end_p)<br>
{<br> first =3D std::find_if(first, last, begin_p);<br><br> </span><c=
ode><code><span><code><span><span style=3D"color:#660"></span></span></code=
><code><span><span style=3D"color:#660"><code><span><span style=3D"color:#0=
00"></span><span style=3D"color:#606">InputIt</span><span style=3D"color:#6=
60"></span></span></code></span></span><span style=3D"color:#660"> </span><=
/code></span></code></code><span style=3D"color:#606">sub_last =3D std::fin=
d_if(first, last, end_p);<br>
<br> if(sub_last !=3D last)<br> ++sub_last;<br><br> return {fi=
rst, sub_last};<br>}</span><span style=3D"color:#660"></span></div></code><=
/div></span></pre></div></div>
</td></tr>
<tr><th> <br>Third version</th></tr><tr><td><div dir=3D"ltr" style=3D"text-=
align:left"><div><pre><span><div style=3D"background-color:rgb(250,250,250)=
;border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wra=
p:break-word">
<code><div><span style=3D"color:#606">template<class </span><code><code>=
<span><code><span><span style=3D"color:#660"></span></span></code><code><sp=
an><span style=3D"color:#660"><code><span><span style=3D"color:#000"></span=
><span style=3D"color:#606">InputIt</span><span style=3D"color:#660"></span=
></span></code></span></span><span style=3D"color:#660"></span></code></spa=
n></code></code><span style=3D"color:#606">, class A, class B><br>
std::pair<</span><code><code><span><code><span><span style=3D"color:#660=
"></span></span></code><code><span><span style=3D"color:#660"><code><span><=
span style=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><=
span style=3D"color:#660"></span></span></code></span></span><span style=3D=
"color:#660"></span></code></span></code></code><span style=3D"color:#606">=
, </span><code><code><span><code><span><span style=3D"color:#660"></span></=
span></code><code><span><span style=3D"color:#660"><code><span><span style=
=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><span style=
=3D"color:#660"></span></span></code></span></span><span style=3D"color:#66=
0"></span></code></span></code></code><span style=3D"color:#606">> extra=
ct_between(</span><code><code><span><code><span><span style=3D"color:#660">=
</span></span></code><code><span><span style=3D"color:#660"><code><span><sp=
an style=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><sp=
an style=3D"color:#660"></span></span></code></span></span><span style=3D"c=
olor:#660"> </span></code></span></code></code><span style=3D"color:#606"><=
code><code><span><span style=3D"color:#660">first</span></span></code></cod=
e>, </span><code><code><span><code><span><span style=3D"color:#660"></span>=
</span></code><code><span><span style=3D"color:#660"><code><span><span styl=
e=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><span styl=
e=3D"color:#660"></span></span></code></span></span><span style=3D"color:#6=
60"> </span></code></span></code></code><span style=3D"color:#606">last, A =
const& begin_value, B const& end_value)<br>
{<br> first =3D std::find(first, last, a);<br><br> if(first !=3D last=
)<br> ++first;<br><br> return {first, std::find(first, last, b)};=
<br>}</span><span style=3D"color:#606"></span><span style=3D"color:#660"></=
span></div>
</code></div><br></span></pre></div></div>
</td></tr><tr><th><table><tbody><tr><th> Fourth version</th></tr><tr><td><d=
iv dir=3D"ltr" style=3D"text-align:left"><div><pre><span><div style=3D"back=
ground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:so=
lid;border-width:1px;word-wrap:break-word">
<code><div><span style=3D"color:#606">template<class </span><code><code>=
<span><code><span><span style=3D"color:#660"></span></span></code><code><sp=
an><span style=3D"color:#660"><code><span><span style=3D"color:#000"></span=
><span style=3D"color:#606">InputIt</span><span style=3D"color:#660"></span=
></span></code></span></span><span style=3D"color:#660"></span></code></spa=
n></code></code><span style=3D"color:#606">, class A, class B><br>
std::pair<</span><code><code><span><code><span><span style=3D"color:#660=
"></span></span></code><code><span><span style=3D"color:#660"><code><span><=
span style=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><=
span style=3D"color:#660"></span></span></code></span></span><span style=3D=
"color:#660"></span></code></span></code></code><span style=3D"color:#606">=
, </span><code><code><span><code><span><span style=3D"color:#660"></span></=
span></code><code><span><span style=3D"color:#660"><code><span><span style=
=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><span style=
=3D"color:#660"></span></span></code></span></span><span style=3D"color:#66=
0"></span></code></span></code></code><span style=3D"color:#606">> extra=
ct_between_if(</span><code><code><span><code><span><span style=3D"color:#66=
0"></span></span></code><code><span><span style=3D"color:#660"><code><span>=
<span style=3D"color:#000"></span><span style=3D"color:#606">InputIt</span>=
<span style=3D"color:#660"></span></span></code></span></span><span style=
=3D"color:#660"> </span></code></span></code></code><span style=3D"color:#6=
06"><code><code><span><span style=3D"color:#660">first</span></span></code>=
</code>, </span><code><code><span><code><span><span style=3D"color:#660"></=
span></span></code><code><span><span style=3D"color:#660"><code><span><span=
style=3D"color:#000"></span><span style=3D"color:#606">InputIt</span><span=
style=3D"color:#660"></span></span></code></span></span><span style=3D"col=
or:#660"> </span></code></span></code></code><span style=3D"color:#606">las=
t, A begin_p, B const& end_p)<br>
{<br> first =3D std::find_if(first, last, a);<br><br> if(first !=3D l=
ast)<br> ++first;<br><br> return {first, std::find_if(first, last=
, b)};<br>}</span><span style=3D"color:#606"></span><span style=3D"color:#6=
60"></span></div>
</code></div><br><br></span></pre></div></div>
</td></tr><tr><th><h3><span>Example</span></h3>
<div><p> The following example finds a tag in a vector of char representing=
a list of tags.
</p><div><div>Run this code</div></div>
<div dir=3D"ltr" style=3D"text-align:left"><div><pre><div style=3D"backgrou=
nd-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;=
border-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#800=
">#include</span><span style=3D"color:#000"> </span><span style=3D"color:#0=
80"><iostream></span><span style=3D"color:#000"><br>
</span><span style=3D"color:#800">#include</span><span style=3D"color:#000"=
> </span><span style=3D"color:#080"><algorithm></span><span style=3D"=
color:#000"><br></span><span style=3D"color:#800">#include</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#080"><string></span><s=
pan style=3D"color:#000"><br>
=C2=A0 </span><span style=3D"color:#008"><br>int</span><span style=3D"colo=
r:#000"> main</span><span style=3D"color:#660">()</span><span style=3D"colo=
r:#000"><br></span><span style=3D"color:#660">{</span><span style=3D"color:=
#000"><br> std</span><span style=3D"color:#660">::</span><span style=3D"=
color:#000">vector</span><span style=3D"color:#080"><int></span><span=
style=3D"color:#000"> v </span><span style=3D"color:#660">=3D</span><span =
style=3D"color:#000"> </span><span style=3D"color:#660">{</span><span style=
=3D"color:#066">1</span><span style=3D"color:#660">,</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#066">2</span><span style=3D"color:=
#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#066"=
>5</span><span style=3D"color:#660">,</span><span style=3D"color:#000"> </s=
pan><span style=3D"color:#066">4</span><span style=3D"color:#660">,</span><=
span style=3D"color:#000"> </span><span style=3D"color:#066">6</span><span =
style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=
=3D"color:#066">2</span><span style=3D"color:#660">,</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#066">3</span><span style=3D"color:=
#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#066"=
>4</span><span style=3D"color:#660">};<br>
</span><span style=3D"color:#000"><br> </span><span style=3D"color:#008"=
>auto</span><span style=3D"color:#000"> result1_pair_it </span><span style=
=3D"color:#660">=3D</span><span style=3D"color:#000"> std</span><span style=
=3D"color:#660">::</span><span style=3D"color:#000">extract</span><span sty=
le=3D"color:#660">(</span><a href=3D"http://en.cppreference.com/w/cpp/itera=
tor/begin" target=3D"_blank"><span style=3D"color:#000">std</span><span sty=
le=3D"color:#660">::</span><span style=3D"color:#008">begin</span></a><span=
style=3D"color:#660">(</span><span style=3D"color:#000">v</span><span styl=
e=3D"color:#660">),</span><span style=3D"color:#000"> </span><a href=3D"htt=
p://en.cppreference.com/w/cpp/iterator/end" target=3D"_blank"><span style=
=3D"color:#000">std</span><span style=3D"color:#660">::</span><span style=
=3D"color:#008">end</span></a><span style=3D"color:#660">(</span><span styl=
e=3D"color:#000">v</span><span style=3D"color:#660">),</span><span style=3D=
"color:#000"> </span><span style=3D"color:#066">5</span><span style=3D"colo=
r:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:#06=
6">2</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><=
br>
<br> =C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"c=
olor:#000">vector result1</span><span style=3D"color:#660">(</span><span st=
yle=3D"color:#000">result1_pair_it</span><span style=3D"color:#660">.</span=
><span style=3D"color:#000">first</span><span style=3D"color:#660">,</span>=
<span style=3D"color:#000"> result1_pair_it</span><span style=3D"color:#660=
">.</span><span style=3D"color:#000">second</span><span style=3D"color:#660=
">);</span><span style=3D"color:#000"><br>
</span><span style=3D"color:#008"> for</span><span style=3D"color:#660">=
(</span><span style=3D"color:#008">auto</span><span style=3D"color:#000"> i=
</span><span style=3D"color:#660">:</span><span style=3D"color:#000"> resu=
lt1</span><span style=3D"color:#660">)</span><span style=3D"color:#000"><br=
>
=C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"c=
olor:#000">cout </span><span style=3D"color:#660"><<</span><span styl=
e=3D"color:#000"> i </span><span style=3D"color:#660"><<</span><span =
style=3D"color:#000"> </span><span style=3D"color:#080">' '</span><=
span style=3D"color:#660">;</span><span style=3D"color:#000"><br>
<br>=C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"c=
olor:#000">cout </span><span style=3D"color:#660"><<</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#080">'\n'</span><spa=
n style=3D"color:#660">;</span><span style=3D"color:#000"><br>
<br>=C2=A0 </span><span style=3D"color:#008">auto</span><span style=3D"co=
lor:#000"> result2_pair_it </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000"> std</span><span style=3D"color:#660">::</span><span=
style=3D"color:#000">extract_between</span><span style=3D"color:#660">(</s=
pan><a href=3D"http://en.cppreference.com/w/cpp/iterator/begin" target=3D"_=
blank"><span style=3D"color:#000">std</span><span style=3D"color:#660">::</=
span><span style=3D"color:#008">begin</span></a><span style=3D"color:#660">=
(</span><span style=3D"color:#000">v</span><span style=3D"color:#660">),</s=
pan><span style=3D"color:#000"> </span><a href=3D"http://en.cppreference.co=
m/w/cpp/iterator/end" target=3D"_blank"><span style=3D"color:#000">std</spa=
n><span style=3D"color:#660">::</span><span style=3D"color:#008">end</span>=
</a><span style=3D"color:#660">(</span><span style=3D"color:#000">v</span><=
span style=3D"color:#660">),</span><span style=3D"color:#000"> </span><span=
style=3D"color:#066">5</span><span style=3D"color:#660">,</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#066">2</span><span style=3D"=
color:#660">);</span><span style=3D"color:#000"><br>
<br>=C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"c=
olor:#000">vector result2</span><span style=3D"color:#660">(</span><span st=
yle=3D"color:#000">result2_pair_it</span><span style=3D"color:#660">.</span=
><span style=3D"color:#000">first</span><span style=3D"color:#660">,</span>=
<span style=3D"color:#000"> result2_pair_it</span><span style=3D"color:#660=
">.</span><span style=3D"color:#000">second</span><span style=3D"color:#660=
">);</span><span style=3D"color:#000"><br>
</span><span style=3D"color:#008">for</span><span style=3D"color:#660">=
(</span><span style=3D"color:#008">auto</span><span style=3D"color:#000"> i=
</span><span style=3D"color:#660">:</span><span style=3D"color:#000"> resu=
lt2</span><span style=3D"color:#660">)</span><span style=3D"color:#000"><br=
>
=C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"c=
olor:#000">cout </span><span style=3D"color:#660"><<</span><span styl=
e=3D"color:#000"> i </span><span style=3D"color:#660"><<</span><span =
style=3D"color:#000"> </span><span style=3D"color:#080">' '</span><=
span style=3D"color:#660">;</span><span style=3D"color:#000"><br>
<br>=C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"c=
olor:#000">cout </span><span style=3D"color:#660"><<</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#080">'\n'</span><spa=
n style=3D"color:#660">;</span><span style=3D"color:#000"><br>
<br>=C2=A0 </span><span style=3D"color:#008">auto</span><span style=3D"co=
lor:#000"> result3_pair_it </span><span style=3D"color:#660">=3D</span><spa=
n style=3D"color:#000"> std</span><span style=3D"color:#660">::</span><span=
style=3D"color:#000">extract_between_if</span><span style=3D"color:#660">(=
</span><a href=3D"http://en.cppreference.com/w/cpp/iterator/begin" target=
=3D"_blank"><span style=3D"color:#000">std</span><span style=3D"color:#660"=
>::</span><span style=3D"color:#008">begin</span></a><span style=3D"color:#=
660">(</span><span style=3D"color:#000">v</span><span style=3D"color:#660">=
),</span><span style=3D"color:#000"> </span><a href=3D"http://en.cppreferen=
ce.com/w/cpp/iterator/end" target=3D"_blank"><span style=3D"color:#000">std=
</span><span style=3D"color:#660">::</span><span style=3D"color:#008">end</=
span></a><span style=3D"color:#660">(</span><span style=3D"color:#000">v</s=
pan><span style=3D"color:#660">),</span><span style=3D"color:#000"><br>
</span><span style=3D"co=
lor:#660">[](</span><span style=3D"color:#008">int</span><span style=3D"col=
or:#000"> i</span><span style=3D"color:#660">){</span><span style=3D"color:=
#000"> </span><span style=3D"color:#008">return</span><span style=3D"color:=
#000"> i </span><span style=3D"color:#660">></span><span style=3D"color:=
#000"> </span><span style=3D"color:#066">5</span><span style=3D"color:#660"=
>;</span><span style=3D"color:#000"> </span><span style=3D"color:#660">},</=
span><span style=3D"color:#660"><br>
[](</span><span style=3D=
"color:#008">int</span><span style=3D"color:#000"> i</span><span style=3D"c=
olor:#660">){</span><span style=3D"color:#000"> </span><span style=3D"color=
:#008">return</span><span style=3D"color:#000"> i </span><span style=3D"col=
or:#660">></span><span style=3D"color:#000"> </span><span style=3D"color=
:#066">10</span><span style=3D"color:#660">;</span><span style=3D"color:#00=
0"> </span><span style=3D"color:#660">});</span><span style=3D"color:#000">=
<br>
<br>=C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"c=
olor:#000">vector result3</span><span style=3D"color:#660">(</span><span st=
yle=3D"color:#000">result3_pair_it</span><span style=3D"color:#660">.</span=
><span style=3D"color:#000">first</span><span style=3D"color:#660">,</span>=
<span style=3D"color:#000"> result3_pair_it</span><span style=3D"color:#660=
">.</span><span style=3D"color:#000">second</span><span style=3D"color:#660=
">);</span><span style=3D"color:#000"><br>
</span><span style=3D"color:#008">for</span><span style=3D"color:#660">=
(</span><span style=3D"color:#008">auto</span><span style=3D"color:#000"> i=
</span><span style=3D"color:#660">:</span><span style=3D"color:#000"> resu=
lt3</span><span style=3D"color:#660">)</span><span style=3D"color:#000"><br=
>
=C2=A0 std</span><span style=3D"color:#660">::</span><span style=3D"c=
olor:#000">cout </span><span style=3D"color:#660"><<</span><span styl=
e=3D"color:#000"> i </span><span style=3D"color:#660"><<</span><span =
style=3D"color:#000"> </span><span style=3D"color:#080">' '</span><=
span style=3D"color:#660">;</span><span style=3D"color:#000"><br>
</span><span style=3D"color:#660">}</span></div></code></div><span><br></sp=
an></pre></div></div>
<p>Output:
</p>
<div dir=3D"ltr" style=3D"text-align:left"><div><pre>5 4 6 2=20
4 6 <br>2 3 4<br></pre></div></div>=20
</div></th></tr><tr><td><br></td></tr></tbody></table></th></tr><tr><td><br=
>I hope you understand the utility of this algorithm. Using it on string is=
frequent too... saves up a lot of substr and find...<br>As i heard the com=
mittee wants new algorithms, what would you recommand=20
about this algorithm ? Is there already a proposal for such an algorithm
? Is there any modification to be made on it so that it fits better to=20
the STL ?<br><br>Thanks for reading at least.<br><br>germinolegrand<br></td=
></tr>
</tbody></table><p>
</p></div>
<p></p>
-- <br>
=C2=A0<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals%2Bunsubscribe@isocpp.org" target=3D=
"_blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</blockquote>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--20cf307d021038d86504f33fd4bc--
.
Author: germinolegrand@gmail.com
Date: Fri, 28 Feb 2014 14:30:15 -0800 (PST)
Raw View
------=_Part_755_7957409.1393626616005
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
You're right, i will correct it in the next version. I'm trying to send a=
=20
mail on the range SG9 mailing-list to have their opinion, but it's an=20
open-std mailing-list, so it's a bit harder to reach them.
Le mardi 25 f=C3=A9vrier 2014 20:09:35 UTC+1, Philipp Stephani a =C3=A9crit=
:
>
> I think these are useful additions. However, the iterators should be=20
> forward iterators, as "first" could be invalidated before return if it's=
=20
> only an input iterator.
>
> [...]
>> ---=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at=20
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
--=20
---=20
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 e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_755_7957409.1393626616005
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">You're right, i will correct it in the next version. I'm t=
rying to send a mail on the range SG9 mailing-list to have their opinion, b=
ut it's an open-std mailing-list, so it's a bit harder to reach them.<br><b=
r>Le mardi 25 f=C3=A9vrier 2014 20:09:35 UTC+1, Philipp Stephani a =C3=A9cr=
it :<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: =
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">I think these are use=
ful additions. However, the iterators should be forward iterators, as "firs=
t" could be invalidated before return if it's only an input iterator.<br><b=
r><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:=
1px #ccc solid;padding-left:1ex">
[...]<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
251a4T0INvoJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.or=
g</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"251a4T0INvoJ" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</blockquote>
</blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_755_7957409.1393626616005--
.