220 39026 <29394898-f878-45ad-b21c-b589e4a36caf@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Justin Bassett <jbassett271@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: __COLUMN__ macro to parallel __LINE__
Date: Sun, 8 Jul 2018 15:20:32 -0700 (PDT)
Lines: 137
Approved: news@gmane.org
Message-ID: <29394898-f878-45ad-b21c-b589e4a36caf@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_102548_978908373.1531088432908"
X-Trace: blaine.gmane.org 1531088308 22710 195.159.176.226 (8 Jul 2018 22:18:28 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 8 Jul 2018 22:18:28 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBC5PL3NYWEDBBMM4RLNAKGQEHGKPAPI@isocpp.org Mon Jul 09 00:18:24 2018
Return-path: <std-proposals+bncBC5PL3NYWEDBBMM4RLNAKGQEHGKPAPI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yb0-f198.google.com ([209.85.213.198])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBC5PL3NYWEDBBMM4RLNAKGQEHGKPAPI@isocpp.org>)
	id 1fcI0d-0005nz-Qq
	for gclcip-std-proposals@m.gmane.org; Mon, 09 Jul 2018 00:18:24 +0200
Original-Received: by mail-yb0-f198.google.com with SMTP id s14-v6sf16223535ybg.7
        for <gclcip-std-proposals@m.gmane.org>; Sun, 08 Jul 2018 15:20:35 -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:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=59c3RSWFePt6JCKQHDv/khyGNQMOFdigyqeQeVBtsYU=;
        b=XVGxlamgicLIrQ3wOG/WpEh6vxVw1Er6ObzxovEev398PADfRnnuefhRG+fkholQqk
         DMpB0V5yfUmhFbJH9r2Dz2CsbJOz7D4xrF7GgZMijJSPktuSZT99nx6L8rTsUbkzn0sa
         C8hKhZoMH2CPH0ELdQJjP7+B+C5ZXga9m8rxr+TxBmA27fF0dNOu4iXn/KExhOxAgs+W
         iyJqkvWGV/H83bDqRv7DRpNe1tqCiH5/BimbrMzqJaeFI8gVcs25+yem3NDu61ghn+Os
         PkZF708d2105NRyfEuMj72h1KtXa45QizI8mT0pg9ChFGaxQGTCPdclURDUiYYeOQjSO
         pPDQ==
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:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=59c3RSWFePt6JCKQHDv/khyGNQMOFdigyqeQeVBtsYU=;
        b=C04u55nwbE/S1/MSs9sYmGFKUyenjlXWjF0sgcLRBC/GZhjy4gRsqvfQcO5GDLik3T
         9QtoWclNn8AoVrotu24cbVp8oUgeQXlji415AIqMSK6lS6pUA3tYPLGU5uTbvEfSQ4uP
         PYTfa0Sfp4pDTztGF2ZSyyw1FzBnhwxUUY+9S3BP8KuYhRG3qc6snpPGl7nRDDi33uVg
         UNo3Nc5uvmrLgw9aRPFb9QKjFqk1r2whK17abvEXoSoJgmZ4g3jQEHIu7yhArOGy3o6T
         Kzol4hIrZpZDuBqD5Rqc8vAJz57scfhnsBAck99TmtOl8drCI/dQufW4WNKKJ8e0HpKf
         nYGg==
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=59c3RSWFePt6JCKQHDv/khyGNQMOFdigyqeQeVBtsYU=;
        b=sd/5sR0pmBOzpJ+EXvFnRhOK/mowFdx5R4Vq2aUfeRVDeWHMGJDtm30B8nsKDBnsEZ
         1/8LbQFMS9+A00RxkSdulES0kRAf86RTuBc90DTnAd/5Q+WqMC/YYQHiq6J4VSJ1ihr1
         LQPOH8Bqd9ihagBJDcqSUt+AmEWGVuGDQtbTpQDJjMp7K0D/0R8F3jAWelh1wnby8RT/
         +iGaRfbeHKNJ6YG2PtdlFCeDK19sECUeB/ibRWceYXi9+cUtxhae5J659ZFdS8bllqIA
         SWiDNo4078x+FYeVZJUSmMjFwftBpZTQY4u+vk5WDzmdtpjnWRus3XHngypxLQ8Mfhr3
         tUvg==
X-Gm-Message-State: APt69E1y2PulHBdxhUv52dICkNeY7ZaZRWQaQsRvGThGVZ7BPtP7UzaR
	ENagzQ+YnNBAdWoIX7nHzk8IAw==
X-Google-Smtp-Source: AAOMgpdadILBBP2E27N2t5QoWHk+Iil1DitBlJ9HxizvoZsdZ9Uz43MTWKKDONybKXNz5/8oPdyhmQ==
X-Received: by 2002:a25:1e87:: with SMTP id e129-v6mr5547183ybe.48.1531088434757;
        Sun, 08 Jul 2018 15:20:34 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a25:320d:: with SMTP id y13-v6ls3476739yby.5.gmail; Sun, 08
 Jul 2018 15:20:33 -0700 (PDT)
X-Received: by 2002:a25:8203:: with SMTP id q3-v6mr2540657ybk.1.1531088433268;
        Sun, 08 Jul 2018 15:20:33 -0700 (PDT)
X-Original-Sender: jbassett271@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: <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:39026
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/39026>

------=_Part_102548_978908373.1531088432908
Content-Type: multipart/alternative; 
	boundary="----=_Part_102549_937995187.1531088432909"

------=_Part_102549_937995187.1531088432909
Content-Type: text/plain; charset="UTF-8"

We have a __LINE__ macro which expands to the source file line number. Why 
not also have __COLUMN__ which expands to the column number?

There are some cases where a unique identifier is desirable, such as 
SCOPE_EXIT. Currently, this identifier has to be generated either by 
__LINE__ or by __COUNTER__, but both have drawbacks: __LINE__ means you 
can't define two on the same line and __COUNTER__ is a recipe for ODR 
violations when used in inline functions in header files. Regardless, 
people do use these:

#define CONCAT_IMPL(A, B) A ## B
#define CONCAT(A, B) CONCAT_IMPL(A, B)

#define UNIQUE_NAME CONCAT(some_prefix_, __LINE__)
// or
#define UNIQUE_NAME CONCAT(some_prefix_, __COUNTER__)

A __COLUMN__ macro would make unique identifiers possible with none of the 
drawbacks of __LINE__ or __COUNTER__:

// Given a ternary preprocessor CONCAT
#define UNIQUE_NAME CONCAT(some_prefix_, __LINE__, __COLUMN__)

I know about std::experimental::source_location, but it's not a macro, so 
it can't do this.

-- 
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/29394898-f878-45ad-b21c-b589e4a36caf%40isocpp.org.

------=_Part_102549_937995187.1531088432909
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">We have a __LINE__ macro which expands to the source file =
line number. Why not also have __COLUMN__ which expands to the column numbe=
r?<div><br></div><div>There are some cases where a unique identifier is des=
irable, such as SCOPE_EXIT. Currently, this identifier has to be generated =
either by __LINE__ or by __COUNTER__, but both have drawbacks: __LINE__ mea=
ns you can&#39;t define two on the same line and __COUNTER__ is a recipe fo=
r ODR violations when used in inline functions in header files. Regardless,=
 people do use these:<br><div><br></div><div><div class=3D"prettyprint" sty=
le=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187=
); border-style: solid; border-width: 1px; word-wrap: break-word;"><code cl=
ass=3D"prettyprint"><div class=3D"subprettyprint"><div style=3D"color: #000=
000;background-color: #fffffe;font-family: Consolas, " liberation=3D"" mono=
",=3D"" courier,=3D"" monospace;font-weight:=3D"" normal;font-size:=3D"" 14=
px;line-height:=3D"" 19px;white-space:=3D"" pre;"=3D""><div><span style=3D"=
color: #0000ff;"><span style=3D"color: #800;" class=3D"styled-by-prettify">=
#define</span></span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> </span><span style=3D"color: rgb(136, 0, 0); background-color: rgb(250=
, 250, 250);"><span style=3D"color: #000;" class=3D"styled-by-prettify">CON=
CAT_IMPL</span></span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">A</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> B</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> A </span><span style=3D"color: #800;=
" class=3D"styled-by-prettify">## B</span></div><div><span style=3D"color: =
#0000ff;"><span style=3D"color: #800;" class=3D"styled-by-prettify">#define=
</span></span><span style=3D"color: #800;" class=3D"styled-by-prettify"> </=
span><span style=3D"background-color: rgb(250, 250, 250);"><span style=3D"c=
olor: #800;" class=3D"styled-by-prettify">CONCAT</span></span><span style=
=3D"color: #800;" class=3D"styled-by-prettify">(A, B) </span><span style=3D=
"color: rgb(0, 0, 0); background-color: rgb(250, 250, 250);"><span style=3D=
"color: #800;" class=3D"styled-by-prettify">CONCAT_IMPL</span></span><span =
style=3D"color: #800;" class=3D"styled-by-prettify">(A, B)</span></div></di=
v><font color=3D"#660066"><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"><br></span></font><div style=3D"color: #000000;background-color: #=
fffffe;font-family: Consolas, " liberation=3D"" mono",=3D"" courier,=3D"" m=
onospace;font-weight:=3D"" normal;font-size:=3D"" 14px;line-height:=3D"" 19=
px;white-space:=3D"" pre;"=3D""><span style=3D"color: #0000ff;"><span style=
=3D"color: #800;" class=3D"styled-by-prettify">#define</span></span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> UNIQUE_NAME </span><spa=
n style=3D"color: rgb(136, 0, 0); background-color: rgb(250, 250, 250);"><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">CONCAT</span></span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">some_prefix_</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> __LINE__</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #800;" cl=
ass=3D"styled-by-prettify">// or</span></div><font color=3D"#660066"><span =
style=3D"color: #800;" class=3D"styled-by-prettify">#define UNIQUE_NAME</sp=
an></font><span style=3D"color: #800;" class=3D"styled-by-prettify"> CONCAT=
(some_prefix_, __COUNTER__)</span></div></code></div><br>A __COLUMN__ macro=
 would make unique identifiers possible with none of the drawbacks of __LIN=
E__ or __COUNTER__:</div><div><br></div><div><div class=3D"prettyprint" sty=
le=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187=
); border-style: solid; border-width: 1px; word-wrap: break-word;"><code cl=
ass=3D"prettyprint"><div class=3D"subprettyprint"><font color=3D"#660066"><=
span style=3D"color: #800;" class=3D"styled-by-prettify">// Given a ternary=
 preprocessor CONCAT</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br></span><span style=3D"color: #800;" class=3D"styled-by-pretti=
fy">#define</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> UNIQUE_NAME </span></font><span style=3D"color: rgb(136, 0, 0);"><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">CONCAT</span></span><font=
 color=3D"#660066"><span style=3D"color: #660;" class=3D"styled-by-prettify=
">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">some_pr=
efix_</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> __LINE__</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> __COLUMN__</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">)</span></font></div></=
code></div></div><div><br></div><div>I know about std::experimental::source=
_location, but it&#39;s not a macro, so it can&#39;t do this.</div></div></=
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/29394898-f878-45ad-b21c-b589e4a36caf%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/29394898-f878-45ad-b21c-b589e4a36caf=
%40isocpp.org</a>.<br />

------=_Part_102549_937995187.1531088432909--

------=_Part_102548_978908373.1531088432908--

.
