220 5588 <03d81e38-a8ae-4c33-9bac-f5a4f9e66eac@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: tomaszkam@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Grouping placeholders for bind
Date: Sat, 27 Jul 2013 03:40:27 -0700 (PDT)
Lines: 170
Approved: news@gmane.org
Message-ID: <03d81e38-a8ae-4c33-9bac-f5a4f9e66eac@isocpp.org>
References: <81385547-bb12-4ae6-9d12-82aaeb4b5ba0@isocpp.org>
 <e41b791b-eaa1-4156-9116-f2f7036ae4ae@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_37_12298667.1374921627853"
X-Trace: ger.gmane.org 1374921628 5307 80.91.229.3 (27 Jul 2013 10:40:28 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 27 Jul 2013 10:40:28 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDNPVXXG6IGBBHGHZ2HQKGQELCH3E7Q@isocpp.org Sat Jul 27 12:40:31 2013
Return-path: <std-proposals+bncBDNPVXXG6IGBBHGHZ2HQKGQELCH3E7Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qe0-f71.google.com ([209.85.128.71])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDNPVXXG6IGBBHGHZ2HQKGQELCH3E7Q@isocpp.org>)
	id 1V31vK-0007uN-Hu
	for gclcip-std-proposals@m.gmane.org; Sat, 27 Jul 2013 12:40:30 +0200
Original-Received: by mail-qe0-f71.google.com with SMTP id 1sf2830655qee.2
        for <gclcip-std-proposals@m.gmane.org>; Sat, 27 Jul 2013 03:40:29 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-beenthere:date:from:to:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-google-group-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=qf22kDN07IVwe3Fo+Lj08ZAHGEzr6HmsKkBDVD9uA2o=;
        b=pxhInYjdscongyeR0D9WBc5n0a50WmUMS3VuhkFEHLabpPf3ENpwhr7Em0vmvUG2f+
         NEaTgosp4lM7fyfMd3S7lQXDKgM8zaqU4dmXSl8WDFTmRUT/61PbStm12+jw6lpI2YJm
         tlSJ7szHdGufxLHH71Xhk5OTYXI/g31ISDoVVDltSNt3Kj9l2AsLb8eQx4/w3CQiFFpE
         oozWT2oOdff8jZz/9i5cRD0Dnucn3sF38GuZmlnSypZJ+PPURLjuyhbEL4lJMlK5EE4Z
         mGbS7PXBngzYxi8FvwKTV9mCHlYwWcltv+5kEm8m36XZFhaA+vMsMjgD9sq9woX+1svY
         sWSQ==
X-Received: by 10.224.163.14 with SMTP id y14mr54289874qax.3.1374921629236;
        Sat, 27 Jul 2013 03:40:29 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.129.233 with SMTP id nz9ls515471qeb.33.gmail; Sat, 27 Jul
 2013 03:40:28 -0700 (PDT)
X-Received: by 10.49.12.47 with SMTP id v15mr690430qeb.39.1374921628358;
        Sat, 27 Jul 2013 03:40:28 -0700 (PDT)
In-Reply-To: <e41b791b-eaa1-4156-9116-f2f7036ae4ae@isocpp.org>
X-Original-Sender: tomaszkam@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: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:5588
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/5588>

------=_Part_37_12298667.1374921627853
Content-Type: text/plain; charset=ISO-8859-1



> The second argument N would mean actual number of argument provided to 
>> invocation of the bind (so we cane genereate index of all arguments)
>>
> Here is the problem. First, the number of (bound) arguments passed to 
> `std::bind` is irrelevant for the placeholders that are needed; these need, 
> if anything, to be determined from the passed callable object. Second, 
> notice that Jonathan specifically did *not* mention any indices. This 
> `std::placeholders::all` form requires a very different implementation that 
> simply forwards all arguments that are passed at the invocation of the 
> returned bind object. It cannot be done with the current interface and 
> numbered placeholders, simply because some functions don't even *have* an 
> upper bound on the number of arguments - variadic templates say hello.
>
> It can be done and to prove it I have prepared the almost standard 
conforming implementation of bind function in C++11 (tested on clang 3.2 
and gcc 4.8.1) that supports customizable group placeholders. The thinks 
that are missing are:
  1. bind<R> - because its add nothing and implementation would be trivial
  2. volatile, const volatile overloads of bind invoke operator - this is 
cause by lack of std::get overload for tuples which such qualification 
(const is supported).
  3. _from<N> is not variable template (not supported)
The implementation can be found on: 
https://github.com/tomaszkam/proposals/tree/master/bind.

Firstly the test cases can be found in test.cpp<https://github.com/tomaszkam/proposals/blob/master/bind/test.cpp>. 
That test includes varidatic template cases and also covers combination of 
group and non group placeholders.

Firstly the new placeholders traits are placed in the file 
placeholder_traits.hpp<https://github.com/tomaszkam/proposals/blob/master/bind/placeholder_traits.hpp>. 
I decided to include new is_placeholder  that forwards to 
std::is_placeholder traits to be sure that new group placeholders won't 
work with std::bind. You may also see default implementation of 
placeholder_positions that provides backward compatibility with single 
argument placeholders definied using only std::is_placeholder. To mark bind 
expression the std::is_bind_expression is used.

The implementation of bind expression is placed in file bind.hpp<https://github.com/tomaszkam/proposals/blob/master/bind/bind.hpp>. 
This implementation has no hardcoded placeholders types and depends only on 
placeholder traits.

The definition of actual grouping placeholders can be found at 
placeholders.hpp<https://github.com/tomaszkam/proposals/blob/master/bind/placeholders.hpp>. 
The _from<N> is at this point alias template but should be changed to 
variable template in future.


Are there any interest in defining group placeholders for the bind? If so I 
think the ability to define custom group placeholders by the user is must 
have, to avoid exponential grow of bind implementation. In the proposed 
approach implementation of _group<2, 3, 7> placeholder (which may be found 
pretty usefull) would look like:

template<std::size_t.... Is>
struct group_placeholder {};

template<std::size_t.... Is>
struct is_placeholder<group_placeholder<Is...>> : true_type {};

template<std::size_t.... Is, std::size_t ArgCount>
struct placeholder_positions<group_placeholder<Is...>, ArgCount> : 
integral_sequence<std::size_t, Is...> 
{
   //static assert to avoid check if  all Is are less ArgCount would be 
recomended but no actually needed.
};

namespace placeholders
{
   template<std::size_t.... Is>
   group_placeholder<Is....> _group;
};

-- 

--- 
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/.



------=_Part_37_12298667.1374921627853
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;"><blockquote style=3D"margi=
n:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex=
" class=3D"gmail_quote"><span><span style=3D"color:rgb(34,34,34)">The secon=
d argument N would mean actual number of argument provided to invocation of=
 the bind (so we cane genereate index of all arguments)</span></span><br></=
blockquote><div>Here is the problem. First, the number of (bound) arguments=
 passed to `std::bind` is irrelevant for the placeholders that are needed; =
these need, if anything, to be determined from the passed callable object. =
Second, notice that Jonathan specifically did <i>not</i> mention any indice=
s. This `std::placeholders::all` form requires a very different implementat=
ion that simply forwards all arguments that are passed at the invocation of=
 the returned bind object. It cannot be done with the current interface and=
 numbered placeholders, simply because some functions don't even *have* an =
upper bound on the number of arguments - variadic templates say hello.<br><=
/div><br></blockquote><div>It can be done and to prove it I have prepared t=
he almost standard conforming implementation of bind function in C++11 (tes=
ted on clang 3.2 and gcc 4.8.1) that supports customizable group placeholde=
rs. The thinks that are missing are:<br>&nbsp; 1. bind&lt;R&gt; - because i=
ts add nothing and implementation would be trivial<br>&nbsp; 2. volatile, c=
onst volatile overloads of bind invoke operator - this is cause by lack of =
std::get overload for tuples which such qualification (const is supported).=
<br>&nbsp; 3. _from&lt;N&gt; is not variable template (not supported)<br>Th=
e implementation can be found on: <a href=3D"https://github.com/tomaszkam/p=
roposals/tree/master/bind">https://github.com/tomaszkam/proposals/tree/mast=
er/bind</a>.<br><br>Firstly the test cases can be found in <a href=3D"https=
://github.com/tomaszkam/proposals/blob/master/bind/test.cpp">test.cpp</a>. =
That test includes varidatic template cases and also covers combination of =
group and non group placeholders.<br><br>Firstly the new placeholders trait=
s are placed in the file <a href=3D"https://github.com/tomaszkam/proposals/=
blob/master/bind/placeholder_traits.hpp">placeholder_traits.hpp</a>. I deci=
ded to include new is_placeholder&nbsp; that forwards to std::is_placeholde=
r traits to be sure that new group placeholders won't work with std::bind. =
You may also see default implementation of placeholder_positions that provi=
des backward compatibility with single argument placeholders definied using=
 only std::is_placeholder. To mark bind expression the std::is_bind_express=
ion is used.<br><br>The implementation of bind expression is placed in file=
 <a href=3D"https://github.com/tomaszkam/proposals/blob/master/bind/bind.hp=
p">bind.hpp</a>. This implementation has no hardcoded placeholders types an=
d depends only on placeholder traits.<br><br>The definition of actual group=
ing placeholders can be found at <a href=3D"https://github.com/tomaszkam/pr=
oposals/blob/master/bind/placeholders.hpp">placeholders.hpp</a>. The _from&=
lt;N&gt; is at this point alias template but should be changed to variable =
template in future.<br><br><br>Are there any interest in defining group pla=
ceholders for the bind? If so I think the ability to define custom group pl=
aceholders by the user is must have, to avoid exponential grow of bind impl=
ementation. In the proposed approach implementation of _group&lt;2, 3, 7&gt=
; placeholder (which may be found pretty usefull) would look like:<br><span=
 style=3D"font-family: courier new,monospace;"><br>template&lt;std::size_t.=
.... Is&gt;<br>struct group_placeholder {};<br><br>template&lt;std::size_t..=
... Is&gt;<br>struct is_placeholder&lt;group_placeholder&lt;Is...&gt;&gt; : =
true_type {};<br><br>template&lt;std::size_t.... Is, std::size_t ArgCount&g=
t;<br>struct placeholder_positions&lt;group_placeholder&lt;Is...&gt;, ArgCo=
unt&gt; : integral_sequence&lt;std::size_t, Is...&gt; <br>{<br>&nbsp;&nbsp;=
 //static assert to avoid check if&nbsp; all Is are less ArgCount would be =
recomended but no actually needed.<br>};<br><br>namespace placeholders<br>{=
<br>&nbsp;&nbsp; template&lt;std::size_t.... Is&gt;<br>&nbsp;&nbsp; group_p=
laceholder&lt;Is....&gt; _group;<br>};</span><br><br></div>

<p></p>

-- <br />
&nbsp;<br />
--- <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 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 />
&nbsp;<br />
&nbsp;<br />

------=_Part_37_12298667.1374921627853--

.
