220 32180 <4d628cb7-c5ac-4d17-ad2e-5d04b9cc9c37@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Viktor Attila Jenei <jenei.viktor@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Idea and solution: Better STD functions and if clause
Date: Tue, 25 Apr 2017 11:13:51 -0700 (PDT)
Lines: 158
Approved: news@gmane.org
Message-ID: <4d628cb7-c5ac-4d17-ad2e-5d04b9cc9c37@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_272_1834101693.1493144031405"
X-Trace: blaine.gmane.org 1493144031 6429 195.159.176.226 (25 Apr 2017 18:13:51 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 25 Apr 2017 18:13:51 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDKJ7DGAVQPRBX5D73DQKGQERRVHGXI@isocpp.org Tue Apr 25 20:13:47 2017
Return-path: <std-proposals+bncBDKJ7DGAVQPRBX5D73DQKGQERRVHGXI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pg0-f72.google.com ([74.125.83.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDKJ7DGAVQPRBX5D73DQKGQERRVHGXI@isocpp.org>)
	id 1d34yB-0001YN-86
	for gclcip-std-proposals@m.gmane.org; Tue, 25 Apr 2017 20:13:47 +0200
Original-Received: by mail-pg0-f72.google.com with SMTP id v20sf35431225pgn.2
        for <gclcip-std-proposals@m.gmane.org>; Tue, 25 Apr 2017 11:13:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=51WKme+QAWVcKyXEU4QuyXcDimGbwV3YaK5khS089AQ=;
        b=YSh+kmr8rSQzuXXWaHHn05e75u4+f6frrh0MA3a8IEN3VniZiXI/Uco1eJ8Ve81tRJ
         iScYFLZ9lJt8ZdHuuP1sxP/CccaOhfSWA9UL5+oMtY/ewJCZBUz6c2WWQshSUhjyYqQP
         9gPDWzE1cOszg9WyDx36+w9UaRmLF02j+63uJcL/23RsnGAfg2K6GIRKT+M1VUG7Flzf
         BAUw+klBeAqQuw31ZAMizfIL/hxIP5yrAIRdC/39lmZPhLLovCJM/BgIvh3y4Pi0eDLX
         gbqdszEEIMwVXUiBZH4+M/aIvtQvcW7jMOpyMsJS2r+cqOrOQWxoEnIl/RdjIaxx7F51
         HE0Q==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:message-id:subject:mime-version:x-original-sender
         :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=51WKme+QAWVcKyXEU4QuyXcDimGbwV3YaK5khS089AQ=;
        b=GYl0wCo5QXhzPjh9DhqgdQclGSYMFkSkGSIJ49M8j1CTH1WA4QMntb3fu+IJ1QE0nG
         Yx/HXBv56lZ20aGhcmEZ1wXI2jT0ZRLwKFgATi6tuvKaUmOM6nrpuzNgFaMLnQFZhZxU
         hBDOPkxwiEsyNzogQnn7N2wXpegmwJQVo51MWVUy+Yp9rsNW1IWnLxb2gOVIa/teZpXa
         Me02Qu0N3bXpzyk3/7Q1wieEZ5TuDW0R6tbovdJau8LyQK8KE/k1pMvMcFvtU13KOJZ+
         UUYCy1uy48BKnN9e8Fyi0eVZHI4lUPf1pGkQ1Nu8i3Vni20TWdkCeXqrpvzDWgQCv4Ym
         Rf5w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:message-id:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=51WKme+QAWVcKyXEU4QuyXcDimGbwV3YaK5khS089AQ=;
        b=ozucDBakO7RVMxPRqmRhBytewSQDyQFaZ2NBr9cUKCjLEovG20S50ydamBjqkAMrQh
         S8/MYc8vuwaQ93ouwRm3AKL5Tl8HYEZCV4hPxJ4xp9w+wozF8EFq+UzyJN1tYQ5IDstN
         GfjV9Q5cgLlA02GNi+h6z8INxlUt73Q5H9CnNqO6Nl8AYNsNuj4LVqQXE5ttjvNVMgFI
         MipfxyVje06UTsWg2FBhrJQrXfOB1Gsl6NlVioqUf8nMA/bLWaeIJp+YvwwCZy9QbdHU
         mphdn7wZc+jt+kcKb1EW/nHAFSzVzivr1Kj71KONGMXHWdmfW60GIRmb/ygMcr6tV+gl
         rkrA==
X-Gm-Message-State: AN3rC/5d/JWyhpi0aoHQH00lwnPuASSSw6f3o6HYIBWZDgjVmLXT071y
	EwZxGcz3MKUwzA==
X-Received: by 10.99.66.66 with SMTP id p63mr15501411pga.141.1493144032851;
        Tue, 25 Apr 2017 11:13:52 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.26.71 with SMTP id u7ls10278626otu.1.gmail; Tue, 25 Apr
 2017 11:13:51 -0700 (PDT)
X-Received: by 10.157.37.213 with SMTP id q79mr354621ota.11.1493144031839;
        Tue, 25 Apr 2017 11:13:51 -0700 (PDT)
X-Original-Sender: jenei.viktor@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:32180
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/32180>

------=_Part_272_1834101693.1493144031405
Content-Type: multipart/alternative; 
	boundary="----=_Part_273_1078324013.1493144031405"

------=_Part_273_1078324013.1493144031405
Content-Type: text/plain; charset=UTF-8

Hello!

  There is a way to be a contributor to the C++ standards? I have some 
ideas, that i want to make.

*1.*
  I think, it could be much better, if the can use std functions only with 
containers and not with begin and end iterators.
  Example the solution:
namespace std
{
    template< typename T >
    using Iterator = typename T::iterator;

    template< typename Cont, typename Pred >
    inline Iterator< Cont > find_if( Cont& c, Pred p )
    {
        

    template< typename Cont, typename Pred >
    inline void for_each( Cont& c, Pred p )
    {
        std::for_each( begin( c ), end( c ), p );
    }

    template< typename Cont >
    inline Iterator< Cont > copy( Cont& in, Cont& out )
    {
        return std::copy( begin( in ), end( in ), begin( out ) );
    }

    template< typename Cont, typename Pred >
    inline Iterator< Cont > copy_if( Cont& in, Cont& out, Pred p )
    {
        return std::copy_if( begin( in ), end( in ), begin( out ), p );
    }
}

  So the programmers can use these functions (and the others too), like: 
   // v is a vector of int
*   for_each( v, []( int& e ) { cout << e << " "; } );*
*   sort( indices, [&v2]( int a, int b ) { return v2[ a ] < v2[ b ]; } );*
*   if (is_sorted( v )) { .... }*

  I think this will be cool, and nice, not?

*2.* 
New if clause (with variable declaration):

*    string result="a.b.c.d";*
*    if ( ( auto f1 = result.rfind('.') ) != std::string::npos) 
result.replace(f1,1,"::");*
*    if ( ( auto f1 = result.rfind('.') ) != std::string::npos) 
result.replace(f1,1,":");*

    These lines could be eq with these code:
    string result="a.b.c.d";
    {
      auto f1 = result.rfind('.');
      if ( f1 != std::string::npos) result.replace(f1,1,"::");
    }
    {
      auto f1 = result.rfind('.');
      if ( f1 != std::string::npos) result.replace(f1,1,":");
    }

What do you think? I can implement all of these, if you want. So, I can 
improve the standards to make a better C++ language. :)

Best regards
Viktor Jenei

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/4d628cb7-c5ac-4d17-ad2e-5d04b9cc9c37%40isocpp.org.

------=_Part_273_1078324013.1493144031405
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hello!<div><br></div><div>=C2=A0 There is a way to be a co=
ntributor to the C++ standards? I have some ideas, that i want to make.</di=
v><div><br></div><div><b>1.</b></div><div>=C2=A0 I think, it could be much =
better, if the can use std functions only with containers and not with begi=
n and end iterators.</div><div>=C2=A0 Example the solution:</div><div><div>=
namespace std</div><div>{</div></div><div><div>=C2=A0 =C2=A0 template&lt; t=
ypename T &gt;</div><div>=C2=A0 =C2=A0 using Iterator =3D typename T::itera=
tor;</div><div><br></div><div>=C2=A0 =C2=A0 template&lt; typename Cont, typ=
ename Pred &gt;</div><div>=C2=A0 =C2=A0 inline Iterator&lt; Cont &gt; find_=
if( Cont&amp; c, Pred p )</div><div>=C2=A0 =C2=A0 {</div><div>=C2=A0 =C2=A0=
 =C2=A0 =C2=A0=C2=A0</div><div><br></div><div>=C2=A0 =C2=A0 template&lt; ty=
pename Cont, typename Pred &gt;</div><div>=C2=A0 =C2=A0 inline void for_eac=
h( Cont&amp; c, Pred p )</div><div>=C2=A0 =C2=A0 {</div><div>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 std::for_each( begin( c ), end( c ), p );</div><div>=C2=A0 =
=C2=A0 }</div><div><br></div><div>=C2=A0 =C2=A0 template&lt; typename Cont =
&gt;</div><div>=C2=A0 =C2=A0 inline Iterator&lt; Cont &gt; copy( Cont&amp; =
in, Cont&amp; out )</div><div>=C2=A0 =C2=A0 {</div><div>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 return std::copy( begin( in ), end( in ), begin( out ) );</div><=
div>=C2=A0 =C2=A0 }</div><div><br></div><div>=C2=A0 =C2=A0 template&lt; typ=
ename Cont, typename Pred &gt;</div><div>=C2=A0 =C2=A0 inline Iterator&lt; =
Cont &gt; copy_if( Cont&amp; in, Cont&amp; out, Pred p )</div><div>=C2=A0 =
=C2=A0 {</div><div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 return std::copy_if( begin( =
in ), end( in ), begin( out ), p );</div><div>=C2=A0 =C2=A0 }</div></div><d=
iv>}</div><div><br></div><div>=C2=A0 So the programmers can use these funct=
ions (and the others too), like:=C2=A0</div><div>=C2=A0 =C2=A0// v is a vec=
tor of int</div><div><b>=C2=A0 =C2=A0for_each( v, []( int&amp; e ) { cout &=
lt;&lt; e &lt;&lt; &quot; &quot;; } );</b></div><div><b>=C2=A0 =C2=A0sort( =
indices, [&amp;v2]( int a, int b ) { return v2[ a ] &lt; v2[ b ]; } );</b><=
/div><div><b>=C2=A0 =C2=A0if (is_sorted( v )) { .... }</b></div><div><br></=
div><div>=C2=A0 I think this will be cool, and nice, not?</div><div><br></d=
iv><div><b>2.</b>=C2=A0</div><div>New if clause (with variable declaration)=
:</div><div><br></div><div><div><b>=C2=A0 =C2=A0 string result=3D&quot;a.b.=
c.d&quot;;</b></div><div><b>=C2=A0 =C2=A0 if ( ( auto f1 =3D result.rfind(&=
#39;.&#39;) ) !=3D std::string::npos) result.replace(f1,1,&quot;::&quot;);<=
/b></div><div><b>=C2=A0 =C2=A0 if ( ( auto f1 =3D result.rfind(&#39;.&#39;)=
 ) !=3D std::string::npos) result.replace(f1,1,&quot;:&quot;);</b></div></d=
iv><div><br></div><div>=C2=A0 =C2=A0 These lines could be eq with these cod=
e:</div><div><div>=C2=A0 =C2=A0 string result=3D&quot;a.b.c.d&quot;;</div><=
div>=C2=A0 =C2=A0 {</div><div>=C2=A0 =C2=A0 =C2=A0 auto f1 =3D result.rfind=
(&#39;.&#39;);</div><div>=C2=A0 =C2=A0 =C2=A0 if ( f1 !=3D std::string::npo=
s) result.replace(f1,1,&quot;::&quot;);</div><div>=C2=A0 =C2=A0 }</div><div=
>=C2=A0 =C2=A0 {</div><div>=C2=A0 =C2=A0 =C2=A0 auto f1 =3D result.rfind(&#=
39;.&#39;);</div><div>=C2=A0 =C2=A0 =C2=A0 if ( f1 !=3D std::string::npos) =
result.replace(f1,1,&quot;:&quot;);</div><div>=C2=A0 =C2=A0 }</div></div><d=
iv><br></div><div>What do you think? I can implement all of these, if you w=
ant. So, I can improve the standards to make a better C++ language. :)</div=
><div><br></div><div>Best regards</div><div>Viktor Jenei</div><div><br></di=
v></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/4d628cb7-c5ac-4d17-ad2e-5d04b9cc9c37%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/4d628cb7-c5ac-4d17-ad2e-5d04b9cc9c37=
%40isocpp.org</a>.<br />

------=_Part_273_1078324013.1493144031405--

------=_Part_272_1834101693.1493144031405--

.
