220 20017 <0a8b46d3-4b38-4e1b-ad75-9d18b4697a97@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Sean Middleditch <sean.middleditch@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Obtaining the number of arguments of a function
Date: Tue, 25 Aug 2015 16:21:52 -0700 (PDT)
Lines: 123
Approved: news@gmane.org
Message-ID: <0a8b46d3-4b38-4e1b-ad75-9d18b4697a97@isocpp.org>
References: <af0ff3cb-51c3-41fe-a91b-200c9a856045@isocpp.org>
 <B7BB5AF6-2654-49A8-B4F5-C1364F007F31@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1668_1981265978.1440544912905"
X-Trace: ger.gmane.org 1440544923 26133 80.91.229.3 (25 Aug 2015 23:22:03 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 25 Aug 2015 23:22:03 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCDODCNR2QPRBEXR6OXAKGQEMB4QAPI@isocpp.org Wed Aug 26 01:21:58 2015
Return-path: <std-proposals+bncBCDODCNR2QPRBEXR6OXAKGQEMB4QAPI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vk0-f69.google.com ([209.85.213.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCDODCNR2QPRBEXR6OXAKGQEMB4QAPI@isocpp.org>)
	id 1ZUNXQ-0000Z3-T9
	for gclcip-std-proposals@m.gmane.org; Wed, 26 Aug 2015 01:21:57 +0200
Original-Received: by vkd66 with SMTP id 66sf208866017vkd.3
        for <gclcip-std-proposals@m.gmane.org>; Tue, 25 Aug 2015 16:21:56 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :content-type: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=v3Fch86UAaXwvZrXOtJbpuxZYdLg3szk7acShFSC2YY=;
        b=E40PllSFw/ELPnbbaunvYnyX9tsb1plIixdrH0NfKFQwU+5/ZO0CTLIEnxeHkUJSOk
         ZNwvOcEneXNEE0rYO0CRc56EmFSTw9+FVgdgZANUtI21s3rIg+LL29cvbBHSsKuri5ZO
         XQg6ZQM6DtZCgdE9gC65Kns+ej9jtW8a3kHQyGqTtS26dZSZWoTf8MfLzTsS5K06BTKK
         H/sPASs+TyZfaFO/4U6Tph+hKQeeZ2dcR9fiPEH6wiMzr4XnfDrm9vlJ7ruwQcz96wUk
         WR4RdVKITQ5dbGpMff/Jh7u/RM9OBVjgwYTEYPXJLXBH9fqkOTLaIxMlGulRWfc19oUw
         6ipw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:content-type: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=v3Fch86UAaXwvZrXOtJbpuxZYdLg3szk7acShFSC2YY=;
        b=QfiNUM+ZBE6brNa42Lmiqqv3YsSNeoMlb0LVBXiW9kCjSbQ/5TKpmuhPkqEnCIcxrw
         SLUD7m1Ci16eq74kZvTncdgQOjKB3cFGkL1vIotTuHyBif+q8nHdunicwpJcFf+qPVLG
         mfI6ZzzKBcaCN3dw3MIqzZCnEeQMidqjfbNnycj8N4AXLAYfAE3x51KWBapkSEOOyQS1
         C3EqQoKD9MoK/kQLidneWO7p7ZuJHiZHKD5p8XxLax/kqUIBW+8BUL+8aRQs6B3nUIrV
         e10XhdgJdF6+rk6//uHljkjFXRZ+4H6mhhKqZCy8PdgtU7J0IVshPn3mv9iJgt0l5UTt
         ZRIw==
X-Gm-Message-State: ALoCoQli3RQxrdfaVZ8Oauv7qt46MKh1YxzEM7DA2GlfVFbrOuF8bWspTbsHsmKHMR+65MrkGzof
X-Received: by 10.129.159.69 with SMTP id w66mr4231303ywg.31.1440544916054;
        Tue, 25 Aug 2015 16:21:56 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.137.102 with SMTP id qh6ls304035igb.37.canary; Tue, 25 Aug
 2015 16:21:54 -0700 (PDT)
X-Received: by 10.50.138.70 with SMTP id qo6mr93647igb.13.1440544914252;
        Tue, 25 Aug 2015 16:21:54 -0700 (PDT)
In-Reply-To: <B7BB5AF6-2654-49A8-B4F5-C1364F007F31@gmail.com>
X-Original-Sender: Sean.Middleditch@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <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: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:20017
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/20017>

------=_Part_1668_1981265978.1440544912905
Content-Type: multipart/alternative; 
	boundary="----=_Part_1669_424219494.1440544912906"

------=_Part_1669_424219494.1440544912906
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Sunday, August 23, 2015 at 1:34:09 AM UTC-7, David Krauss wrote:
>
>
> On 2015=E2=80=9308=E2=80=9323, at 4:03 PM, NDos Dannyu <ndosp...@naver.co=
m <javascript:>>=20
> wrote:
>
> Why this function isn't in the stantard library? It's too easy to=20
> implement!
>
>
> Is the standard library supposed to do everything that=E2=80=99s easy?
>
> *template <class R, class ...Args>*
> *constexpr size_t count_args(R (*)(Args...)) noexcept {*
> *    return sizeof...(Args);*
> *}*
>
>
> This doesn=E2=80=99t handle member function signatures with cv-qualifiers=
 or=20
> ref-qualifiers. Separately, it doesn=E2=80=99t handle member functions (P=
TMFs). It=20
> doesn=E2=80=99t handle C-style varargs signatures, or Callable objects be=
sides=20
> function pointers. It doesn=E2=80=99t tell you about default arguments.
>
> This is *not* easy. I don=E2=80=99t see how it=E2=80=99s useful, either.
>

This is just one piece of boost function_traits=20
(http://www.boost.org/doc/libs/1_57_0/libs/type_traits/doc/html/boost_typet=
raits/reference/function_traits.html)=20
combined with the utility to convert various forms of function pointer into=
=20
the "function type" needed by function_traits=20
(e.g. https://functionalcpp.wordpress.com/2013/08/05/function-traits/)

Very useful for script binding and general runtime reflection systems,=20
among other things. Take a look at libraries like luabind or one of its=20
umpteen bazillion alternatives for examples of where it can be useful.

Suuuper common need in games at the very least, and I'm sure many other=20
places.

Would be nice to have function_traits in the standard.

--=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_1669_424219494.1440544912906
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Sunday, August 23, 2015 at 1:34:09 AM UTC-7, David Krauss wrote:<blockqu=
ote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left=
: 1px #ccc solid;padding-left: 1ex;"><div style=3D"word-wrap:break-word"><b=
r><div><blockquote type=3D"cite"><div>On 2015=E2=80=9308=E2=80=9323, at 4:0=
3 PM, NDos Dannyu &lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfusca=
ted-mailto=3D"x3egsdlZBQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#3=
9;javascript:&#39;;return true;" onclick=3D"this.href=3D&#39;javascript:&#3=
9;;return true;">ndosp...@naver.com</a>&gt; wrote:</div><br><div><div dir=
=3D"ltr"><div>Why this function isn&#39;t in the stantard library? It&#39;s=
 too easy to implement!</div></div></div></blockquote><div><br></div><div>I=
s the standard library supposed to do everything that=E2=80=99s easy?</div>=
<br><blockquote type=3D"cite"><div><div dir=3D"ltr"><div><strong>template &=
lt;class R, class ...Args&gt;</strong></div><div><strong>constexpr size_t c=
ount_args(R (*)(Args...)) noexcept {</strong></div><div><strong>=C2=A0=C2=
=A0=C2=A0 return sizeof...(Args);</strong></div><div><strong>}</strong></di=
v></div></div></blockquote><br></div><div>This doesn=E2=80=99t handle membe=
r function signatures with cv-qualifiers or ref-qualifiers. Separately, it =
doesn=E2=80=99t handle member functions (PTMFs). It doesn=E2=80=99t handle =
C-style varargs signatures, or Callable objects besides function pointers. =
It doesn=E2=80=99t tell you about default arguments.</div><div><br></div><d=
iv>This is <i>not</i>=C2=A0easy. I don=E2=80=99t see how it=E2=80=99s usefu=
l, either.</div></div></blockquote><div><br></div><div>This is just one pie=
ce of boost function_traits (http://www.boost.org/doc/libs/1_57_0/libs/type=
_traits/doc/html/boost_typetraits/reference/function_traits.html) combined =
with the utility to convert various forms of function pointer into the &quo=
t;function type&quot; needed by function_traits (e.g.=C2=A0https://function=
alcpp.wordpress.com/2013/08/05/function-traits/)</div><div><br></div><div>V=
ery useful for script binding and general runtime reflection systems, among=
 other things. Take a look at libraries like luabind or one of its umpteen =
bazillion alternatives for examples of where it can be useful.</div><div><b=
r></div><div>Suuuper common need in games at the very least, and I&#39;m su=
re many other places.<br></div><div><br></div><div>Would be nice to have fu=
nction_traits in the standard.</div>

<p></p>

-- <br />
<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 <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 />
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_1669_424219494.1440544912906--
------=_Part_1668_1981265978.1440544912905--

.
