220 13020 <b91aef20-a4ca-4b17-ae8f-4553fc76a0de@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Vittorio Romeo <vittorio.romeo.vee@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Compile-time static `std::integral_counter`
Date: Fri, 19 Sep 2014 10:40:55 -0700 (PDT)
Lines: 111
Approved: news@gmane.org
Message-ID: <b91aef20-a4ca-4b17-ae8f-4553fc76a0de@isocpp.org>
References: <9a0bde7b-2f0a-4a5b-92a4-88d5e8df7ea9@isocpp.org>
 <B686551F-D10C-4107-9EAB-6487A7128F3F@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_2799_368633182.1411148455858"
X-Trace: ger.gmane.org 1411148466 13930 80.91.229.3 (19 Sep 2014 17:41:06 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 19 Sep 2014 17:41:06 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCO3NDEYZQHRBKOV6GQAKGQEDT67DRI@isocpp.org Fri Sep 19 19:41:00 2014
Return-path: <std-proposals+bncBCO3NDEYZQHRBKOV6GQAKGQEDT67DRI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f69.google.com ([209.85.218.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCO3NDEYZQHRBKOV6GQAKGQEDT67DRI@isocpp.org>)
	id 1XV2B0-0004zh-Pq
	for gclcip-std-proposals@m.gmane.org; Fri, 19 Sep 2014 19:40:59 +0200
Original-Received: by mail-oi0-f69.google.com with SMTP id u20sf14383310oif.0
        for <gclcip-std-proposals@m.gmane.org>; Fri, 19 Sep 2014 10:40:57 -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
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=IQV5l1HjG09e4pHFiHdGASlCo/GeebAGCSKu1747q9Q=;
        b=QHzO3zwsiMSs3NCWLk2Io/ml9tTYg/HFP6IL2uAObFjLBfVL8rtOamA2HUl24uytcS
         sxMNh3C0v14VAub5cCBYTot4AC1wsa7g/cEWMnBK43YQYGUGihB57a+X2wl25L6Pj3hM
         GH9V6h4Pom8fUQZzwXFvqlDmV7t7B0YuoBDcjP9ezRTVYcBdA7evH7agNOrDm/86WzJx
         es7YWddarsmhnFV49HVwNbdwkPWS1k8NUrIt0d0dTnsDJx1IjVGkmKf4F+J9vIFd1JGH
         nlFHeF/S2GTQZehyPoTedV9va3tJBdjhXbVN6rs+HJ/CNwo3skc2VbYkHJASFrBkCd1f
         QvJA==
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:x-original-sender:reply-to:precedence
         :mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=IQV5l1HjG09e4pHFiHdGASlCo/GeebAGCSKu1747q9Q=;
        b=DQ+uMpk4Cr1cXqh00Y9QZTeeL1Pk8RYzVoTO0HVDkND1aXe4yiyhDIsAfeRXvdBsZ4
         +gAudEL6KNaIzFL1zKMfEE+HlGziUfCc2/BDyOqVFy924JD/34JfB474y+ELVlyjcxtg
         BH/WMF3pYJ5uRwrG1lN84ExFF64jqIdesL+9kQ+fpqUFnrWNJK7/wXro5rvEW0E+aRqJ
         KGopHwmBSmYha85eBEA+6B3ZLln+jGA3HgVT4ZTkM1gmQxfHxyJatL8BzYciyuuwKU6y
         C0KGRBllrArgQWZOKp2G6l0krV0hGKmQqSor3lFqze4A7uomYk4pcqwowcvSrDtbh9sh
         ZcFA==
X-Gm-Message-State: ALoCoQnC4MrwpCT08wCVvWQBcZHyJfRbHKBW/ul6vlgbff+z064c4nFr0ISysLlaHEHQGzPJ88HY
X-Received: by 10.182.22.201 with SMTP id g9mr2099354obf.18.1411148457717;
        Fri, 19 Sep 2014 10:40:57 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.101.207 with SMTP id u73ls818847qge.34.gmail; Fri, 19 Sep
 2014 10:40:56 -0700 (PDT)
X-Received: by 10.140.30.246 with SMTP id d109mr47805qgd.7.1411148456967;
        Fri, 19 Sep 2014 10:40:56 -0700 (PDT)
In-Reply-To: <B686551F-D10C-4107-9EAB-6487A7128F3F@gmail.com>
X-Original-Sender: vittorio.romeo.vee@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: <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:13020
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/13020>

------=_Part_2799_368633182.1411148455858
Content-Type: text/plain; charset=UTF-8

On Friday, 19 September 2014 19:13:48 UTC+2, inkwizyt...@gmail.com wrote:
>
> Why don't move this types to one typedef?
> typedef any_variadic_template<A, B, C, D> typeColection;
> template<typename T>
> constexpr int f() { return type_pos_in_param<T, typeColection>::value; }
>
> You can query this type anywhere you want.
>

This requires creating and maintaining a list of types... which it's 
(should be) unnecessary and it's very cumbersome for the user of my 
libraries.

---

On Friday, 19 September 2014 19:23:22 UTC+2, David Krauss wrote:
>
> I see some discussion of the ODR in this thread. Any counter usage with 
> linkage does need to be placed in the header file and repeated exactly the 
> same in each TU. Avoid sharing a counter between headers unless those 
> headers are all-or-nothing.
>

Can you elaborate more on this? What I am currently doing is putting the 
workaround code in an header file (header-only library) and using inline in 
every function. Is that not guaranteed to return expected values in 
different TUs? (values that never repeat, I mean)

-- 

--- 
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_2799_368633182.1411148455858
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><font size=3D"1">On Friday, 19 September 2014 19:13:48 UTC=
+2, inkwizyt...@gmail.com wrote:</font><blockquote class=3D"gmail_quote" st=
yle=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color=
: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div di=
r=3D"ltr"><font size=3D"1">Why don't move this types to one typedef?<br></f=
ont><div style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: break-wo=
rd; background-color: rgb(250, 250, 250);"><code><font size=3D"1"><span sty=
le=3D"color: rgb(0, 0, 136);">typedef</span><span style=3D"color: rgb(0, 0,=
 0);">&nbsp;any_variadic_template</span><span style=3D"color: rgb(102, 102,=
 0);">&lt;</span><span style=3D"color: rgb(0, 0, 0);">A</span><span style=
=3D"color: rgb(102, 102, 0);">,</span><span style=3D"color: rgb(0, 0, 0);">=
&nbsp;B</span><span style=3D"color: rgb(102, 102, 0);">,</span><span style=
=3D"color: rgb(0, 0, 0);">&nbsp;C</span><span style=3D"color: rgb(102, 102,=
 0);">,</span><span style=3D"color: rgb(0, 0, 0);">&nbsp;D</span><span styl=
e=3D"color: rgb(102, 102, 0);">&gt;</span><span style=3D"color: rgb(0, 0, 0=
);">&nbsp;typeColection</span><span style=3D"color: rgb(102, 102, 0);">;</s=
pan><span style=3D"color: rgb(0, 0, 0);"><br></span><span style=3D"color: r=
gb(0, 0, 136);">template</span><span style=3D"color: rgb(102, 102, 0);">&lt=
;</span><span style=3D"color: rgb(0, 0, 136);">typename</span><span style=
=3D"color: rgb(0, 0, 0);">&nbsp;T</span><span style=3D"color: rgb(102, 102,=
 0);">&gt;</span><span style=3D"color: rgb(0, 0, 0);"><br></span><span styl=
e=3D"color: rgb(0, 0, 136);">constexpr</span><span style=3D"color: rgb(0, 0=
, 0);">&nbsp;</span><span style=3D"color: rgb(0, 0, 136);">int</span><span =
style=3D"color: rgb(0, 0, 0);">&nbsp;f</span><span style=3D"color: rgb(102,=
 102, 0);">()</span><span style=3D"color: rgb(0, 0, 0);">&nbsp;</span><span=
 style=3D"color: rgb(102, 102, 0);">{</span><span style=3D"color: rgb(0, 0,=
 0);">&nbsp;</span><span style=3D"color: rgb(0, 0, 136);">return</span><spa=
n style=3D"color: rgb(0, 0, 0);">&nbsp;type_pos_in_param</span><span style=
=3D"color: rgb(102, 102, 0);">&lt;</span><span style=3D"color: rgb(102, 102=
, 0);"><code><span style=3D"color: rgb(0, 0, 0);">T, typeColection</span></=
code>&gt;</span><span style=3D"color: rgb(0, 0, 0);">::value;&nbsp;</span><=
span style=3D"color: rgb(102, 102, 0);">}</span><span style=3D"color: rgb(0=
, 0, 0);"><br></span></font></code></div><font size=3D"1"><br>You can query=
 this type anywhere you want.</font></div></blockquote><div><br></div><div>=
This requires creating and maintaining a list of types... which it's (shoul=
d be) unnecessary and it's very cumbersome for the user of my libraries.</d=
iv><div><br></div><div>---</div><br><font size=3D"1">On Friday, 19 Septembe=
r 2014 19:23:22 UTC+2, David Krauss  wrote:</font><blockquote class=3D"gmai=
l_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;=
padding-left: 1ex;"><div style=3D"word-wrap:break-word"><div><div><font siz=
e=3D"1">I see some discussion of the ODR in this thread. Any counter usage =
with linkage does need to be placed in the header file and repeated exactly=
 the same in each TU. Avoid sharing a counter between headers unless those =
headers are all-or-nothing.</font></div></div></div></blockquote><div><br><=
/div><div>Can you elaborate more on this? What I am currently doing is putt=
ing the workaround code in an header file (header-only library) and using i=
nline in every function. Is that not guaranteed to return expected values i=
n different TUs? (values that never repeat, I mean)</div></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_2799_368633182.1411148455858--

.
