220 40213 <CAJ2mQS05Y8ezjYnWwdaj7xxa0=5etZPKBUvkDNtbXCvt=uf_Tg@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Sarfaraz Nawaz <nawazzz@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Global operator overriding
Date: Sun, 23 Sep 2018 13:06:09 +0530
Lines: 137
Approved: news@gmane.org
Message-ID: <CAJ2mQS05Y8ezjYnWwdaj7xxa0=5etZPKBUvkDNtbXCvt=uf_Tg@mail.gmail.com>
References: <21428a88-efb7-4648-86c6-5dbf19b96519@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="0000000000009e2983057684ed21"
X-Trace: blaine.gmane.org 1537688054 22411 195.159.176.226 (23 Sep 2018 07:34:14 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 23 Sep 2018 07:34:14 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDIJVR7DRYKRB4UETXOQKGQEHT6LJKQ@isocpp.org Sun Sep 23 09:34:10 2018
Return-path: <std-proposals+bncBDIJVR7DRYKRB4UETXOQKGQEHT6LJKQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ua1-f69.google.com ([209.85.222.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDIJVR7DRYKRB4UETXOQKGQEHT6LJKQ@isocpp.org>)
	id 1g3yu9-0005hN-Dj
	for gclcip-std-proposals@m.gmane.org; Sun, 23 Sep 2018 09:34:09 +0200
Original-Received: by mail-ua1-f69.google.com with SMTP id f12-v6sf338451uan.1
        for <gclcip-std-proposals@m.gmane.org>; Sun, 23 Sep 2018 00:36:19 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1537688179; cv=pass;
        d=google.com; s=arc-20160816;
        b=iYJ9keO5CHaKdxUOPwnwFoKO7TsSjmu+nY54ML2JIIonuOAGW7HhlbXLMgWK9oRvRv
         4CJisoHJ2xhsb8mmaKpBJfX8ApWnnPahWTF5RH4Bc/kWydfMhZzb0DpZhRL4RN/Zrft3
         jWCYftIdnJYGnOpC9o41TbrpOwmP8WKxmUE+TIb6VfaHFL7QOdTERoVwGUqPUDHIXH+z
         fORVqAZHS7mhxHjkd6UkCmnfwvx/zzQP3UQoD4ykWKjkz9dgS0E7sP3g86UxUEfDI4u3
         oREKQfBlA2RDtcPCIvxdIFhwzYbztbv5G/jkSDr2URs8mdtkNNK0ehwAfH9pf1v8UvfP
         AeyA==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:in-reply-to:references:mime-version:dkim-signature;
        bh=bUJav0jpYC9Bwm7f3dHuf/Ev52uTCb0kUlAsKzsnTVw=;
        b=AJqytD+x/m0CreZu6EnV2p0EWU+M+ryDVaaoOl4Xy5FIt6objwlhbEVZZ1JBEIqpaJ
         x8QQ4FMhAIOnptotVo/7ZjgleQj+xwH+nzp0zlbh9pg4nkhcJHW+RP7oBiD91xdaiezO
         +puGvaFLDdEoBwNisB2ZJPsLVNeTTAbn7q8aaLK/aRJvRMh2vRKBxfXqy+Ks53VuT+Ye
         iESTeS7K2SAmm+yNzG8KIcUCZQmJFWvcAiuE7lUUV2mc7DDOCdbS7hFaxVpvvYqIALBk
         ktkwL20tVWwGFIdm3zs4HTDPtl4iRcoob6NFpbcOG1DZd4Y50TBzYSWkjqTGOjoPly1e
         +R5g==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=OUoQliaZ;
       spf=pass (google.com: domain of nawazzz@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=nawazzz@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:references:in-reply-to:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=bUJav0jpYC9Bwm7f3dHuf/Ev52uTCb0kUlAsKzsnTVw=;
        b=a+pKDx+fZC9dSTJNyJg76Mxfu5o+i0fvAaxU6s1INfYb3A35GSBFmDLz+jE4LDpu6L
         m4h3FcsoBd7S2faDlHwPKTiq/jXtu51WhaTyvdaXZBNr9tQyQpHA6Mkkvx2s4hTQACwC
         uUY4BqQZbgCMo+H85tBad+rRFiR7VGn7aI47yQlpABGy96QDo7f3hx3PjkHZs3v6ZU4S
         JRlJX2FFnpDD70QAl7LYRISxOmLbJ+ECgGjXu+H0ViDoDEK1H5xD7QU/jb4SFpLzcj0D
         ZrGyIYYkhRqk0+ZydtP1V4mQY6CmdA846uzHIA2j/DMv3N7q9ieaxVvSLHYlhf811qA/
         HTLg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:references:in-reply-to:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=bUJav0jpYC9Bwm7f3dHuf/Ev52uTCb0kUlAsKzsnTVw=;
        b=sr6frAzC1xfLGepkXZOs159NJ0bwioULLUqNCQsg30JWitq0pyag/qmlSJaqb2KmkJ
         opHjd2xWLlWw5lIoUNBbpuQ/3GXA+wqedhbbBQhWBwZ2mxcNv4ghLiMUB/1IjwDw74hq
         JzIntub4E4R/EN6TMz3YplgS61jlEqiVrJlnc80URFLiu5Rl2lwctnI3UUh9vqGk21ZY
         I7UcELAdpos2+1cmDHSWqV7+TxYAfi/XVX5QqdgqwUWf+XDCpDPrg4DsfoyF8PUCLTzp
         Enr9xVkgwtGb7l8xOQY3vsg9Fv6YeUfWGZ3PYpjnhj2BF9QM09o2Q2fItLvEmatnFRti
         26ag==
X-Gm-Message-State: APzg51CeRrvVQv0I/b1acSYC+DwyMf1GOkr+Il27AnIpqgzoZ8cu7YUb
	1XDzZc38tfkB9JQ+5ZhNnwD8LA==
X-Google-Smtp-Source: ANB0VdYZvMZupDmeM1dFZkGOlC1vyHEs3wXp3bT2aNAfwv/tzFLTmpU8vyXqvJYIj+AUu6Dm9AVAIQ==
X-Received: by 2002:a67:7a43:: with SMTP id v64-v6mr1688096vsc.6.1537688179276;
        Sun, 23 Sep 2018 00:36:19 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a67:7449:: with SMTP id p70-v6ls657935vsc.1.gmail; Sun, 23
 Sep 2018 00:36:18 -0700 (PDT)
X-Received: by 2002:a67:cd07:: with SMTP id u7-v6mr1155165vsl.78.1537688178237;
        Sun, 23 Sep 2018 00:36:18 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1537688178; cv=none;
        d=google.com; s=arc-20160816;
        b=EA0JAvlKAlCQH+q553Tfg04Bjv/CbTX/pU6oLLpFVqs1o2SbHBGpgYDkAqDChyCiRX
         N3uJ5EREhDxxjb3vQnah8b2bCFRkLUyY1foxTK7Rgvtl78o0leucAz8avh5jFx0SaXBq
         TF9eDW94rpD/4kMH+kd5JdOetW1Q8N8HpqeP+Hzu09yI1quza77kTZeYpGy58Jaco2T1
         dqralFalY12g/tm7Mtp3wM9Bol6H4RjWTOvRBRVFm21rwRgchkZeoG9zNJzC4i6OCe/b
         bKadY2niaMuy6PrISTQvaF0p80XRw9M3DYCizqW5QA7kJseFuH2l7Ziw5+7Uh43i/hvF
         fZyQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:in-reply-to:references:mime-version
         :dkim-signature;
        bh=PtSYyTm/xS1WI+ew3/wOCwsgJ40ZEXezFFnPQF4scLI=;
        b=z+Wh8q/7yE/FxR6nBNMzHGvSCoUI2qvseJ/To5yBHR6FAtru79yMaMU1d3+WajWuax
         d0MXcX5zR5cC2ZL9AGUe3azvdT1bWKjFgbI6sFP/kcLVjISoppa/PY8+iyt5rc51JEwr
         97aFnoLn08HuN3+OQaN4yUTwh8mcwbKRmxTGRC9ZlH6V8R25VX0381HLFx6yokspq0ob
         J4Tyyaj8Sc+l72zsq+vctY+dbd0RF4EaMebpq1F8XfeudyD9A3okoOpySR/ctrXWSLYJ
         yE2Huo4gC1lCK1/dB1VhY7JQoSAsGA+5/aM4v6+Avspr7lqnu8ctQbGlGQuBDtiipPtQ
         NVfg==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=OUoQliaZ;
       spf=pass (google.com: domain of nawazzz@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=nawazzz@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65])
        by mx.google.com with SMTPS id x9-v6sor8441778vsk.84.2018.09.23.00.36.18
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Sun, 23 Sep 2018 00:36:18 -0700 (PDT)
Received-SPF: pass (google.com: domain of nawazzz@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65;
X-Received: by 2002:a67:6584:: with SMTP id z126-v6mr1155172vsb.173.1537688177877;
 Sun, 23 Sep 2018 00:36:17 -0700 (PDT)
In-Reply-To: <21428a88-efb7-4648-86c6-5dbf19b96519@isocpp.org>
X-Original-Sender: nawazzz@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=OUoQliaZ;       spf=pass
 (google.com: domain of nawazzz@gmail.com designates 209.85.220.65 as
 permitted sender) smtp.mailfrom=nawazzz@gmail.com;       dmarc=pass (p=NONE
 sp=QUARANTINE dis=NONE) header.from=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:40213
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40213>

--0000000000009e2983057684ed21
Content-Type: text/plain; charset="UTF-8"

return _left + _right;


Is this  a recursive call?

On Sat, Sep 22, 2018 at 4:39 PM Denis Kotov <redradist@gmail.com> wrote:

> Hello everyone,
>
> I have faced with an issue when I want for all numeric types create
> general mechanize of checking for overflowing, but to make it optional.
> *My Proposal* is to add possibility to override global operators to make
> possible to add logic for overflow checking:
>
> template <typename TLeft, typename TRight>
> constexpr inline auto operator +(TLeft _left, TRight _right) -> decltype(_left + _right) {
>   if (typeid(decltype(_left + _right)) == typeid(TLeft)) {
>     // Implementation of checking of overflow
>     // For example: If overflow throw exception
>   } else {
>     // Implementation of checking of overflow
>     // For example: If overflow throw exception
>   }
>   return _left + _right;
> }
>
> What do you think about such solution ?
>
> --
> 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/21428a88-efb7-4648-86c6-5dbf19b96519%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/21428a88-efb7-4648-86c6-5dbf19b96519%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAJ2mQS05Y8ezjYnWwdaj7xxa0%3D5etZPKBUvkDNtbXCvt%3Duf_Tg%40mail.gmail.com.

--0000000000009e2983057684ed21
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><blockquote style=3D"margin:0 0 0 40px;border:none;pad=
ding:0px"><font size=3D"2"><span style=3D"color:rgb(0,0,128);font-weight:bo=
ld">return </span>_left + _right;</font></blockquote><blockquote style=3D"m=
argin:0 0 0 40px;border:none;padding:0px"><div><br></div></blockquote>Is th=
is=C2=A0 a recursive call?<br></div><br><div class=3D"gmail_quote"><div dir=
=3D"ltr">On Sat, Sep 22, 2018 at 4:39 PM Denis Kotov &lt;<a href=3D"mailto:=
redradist@gmail.com">redradist@gmail.com</a>&gt; wrote:<br></div><blockquot=
e class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc sol=
id;padding-left:1ex"><div dir=3D"ltr"><div><font size=3D"2">Hello everyone,=
</font></div><div><font size=3D"2"><br></font></div><div><font size=3D"2">I=
 have faced with an issue when I want for all numeric types create general =
mechanize of checking for overflowing, but to make it optional.</font></div=
><div><font size=3D"2"><b>My Proposal</b> is to add possibility to override=
 global operators to make possible to add logic for overflow checking:</fon=
t></div><div><br></div><div><pre style=3D"background-color:#ffffff;color:#0=
00000;font-family:&#39;DejaVu Sans Mono&#39;;font-size:11.3pt"><font size=
=3D"2"><span style=3D"color:#000080;font-weight:bold">template </span>&lt;<=
span style=3D"color:#000080;font-weight:bold">typename </span><span style=
=3D"color:#371f80">TLeft</span>, <span style=3D"color:#000080;font-weight:b=
old">typename </span><span style=3D"color:#371f80">TRight</span>&gt;<br><sp=
an style=3D"color:#000080;font-weight:bold">constexpr inline auto operator =
</span>+(<span style=3D"color:#371f80">TLeft </span>_left, <span style=3D"c=
olor:#371f80">TRight </span>_right) -&gt; <span style=3D"color:#000080;font=
-weight:bold">decltype</span>(_left + _right) {<br>  <span style=3D"color:#=
000080;font-weight:bold">if </span>(<span style=3D"color:#000080;font-weigh=
t:bold">typeid</span>(<span style=3D"color:#000080;font-weight:bold">declty=
pe</span>(_left + _right)) <span style=3D"color:#008080">=3D=3D </span><spa=
n style=3D"color:#000080;font-weight:bold">typeid</span>(<span style=3D"col=
or:#371f80">TLeft</span>)) {<br>    <span style=3D"color:#808080;font-style=
:italic">// Implementation of checking of overflow<br>    // For example: I=
f overflow t</span></font><font size=3D"2"><span style=3D"color:#808080;fon=
t-style:italic"><font size=3D"2"><span style=3D"color:#808080;font-style:it=
alic">hrow exception</span></font></span><span style=3D"color:#808080;font-=
style:italic"><br>  </span>} <span style=3D"color:#000080;font-weight:bold"=
>else </span>{<br>    <span style=3D"color:#808080;font-style:italic">// Im=
plementation of checking of overflow<br></span>    <span style=3D"color:#80=
8080;font-style:italic"><span style=3D"color:#808080;font-style:italic">// =
For example: </span></span></font><font size=3D"2"><span style=3D"color:#80=
8080;font-style:italic"><span style=3D"color:#808080;font-style:italic"></s=
pan></span><span style=3D"color:#808080;font-style:italic"><font size=3D"2"=
><span style=3D"color:#808080;font-style:italic">If overflow t</span></font=
><font size=3D"2"><span style=3D"color:#808080;font-style:italic"><font siz=
e=3D"2"><span style=3D"color:#808080;font-style:italic">hrow exception</spa=
n></font></span><span style=3D"color:#808080;font-style:italic"><br></span>=
</font>  </span>}<br>  <span style=3D"color:#000080;font-weight:bold">retur=
n </span>_left + _right;<br>}</font><br><br><font size=3D"2"><span style=3D=
"font-family:arial,sans-serif">What do you think about such solution ?</spa=
n></font><br></pre></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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">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/21428a88-efb7-4648-86c6-5dbf19b96519%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/21428a88-efb7-=
4648-86c6-5dbf19b96519%40isocpp.org</a>.<br>
</blockquote></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/CAJ2mQS05Y8ezjYnWwdaj7xxa0%3D5etZPKBU=
vkDNtbXCvt%3Duf_Tg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAJ2mQS05Y8ez=
jYnWwdaj7xxa0%3D5etZPKBUvkDNtbXCvt%3Duf_Tg%40mail.gmail.com</a>.<br />

--0000000000009e2983057684ed21--

.
