220 37313 <p85ksl$tij$1@blaine.gmane.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Larry Evans <cppljevans@suddenlink.net>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Pointer overload for ||
Date: Mon, 12 Mar 2018 05:32:52 -0500
Lines: 45
Approved: news@gmane.org
Message-ID: <p85ksl$tij$1@blaine.gmane.org>
References: <1fea07df-46a6-4df2-865a-849be8f8d129@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"; format=flowed
X-Trace: blaine.gmane.org 1520850660 31471 195.159.176.226 (12 Mar 2018 10:31:00 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 12 Mar 2018 10:31:00 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.6.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDAYTI72VMGRBXNOTHKQKGQERMXFNSA@isocpp.org Mon Mar 12 11:30:56 2018
Return-path: <std-proposals+bncBDAYTI72VMGRBXNOTHKQKGQERMXFNSA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f72.google.com ([209.85.215.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDAYTI72VMGRBXNOTHKQKGQERMXFNSA@isocpp.org>)
	id 1evKjH-00085i-Js
	for gclcip-std-proposals@m.gmane.org; Mon, 12 Mar 2018 11:30:55 +0100
Original-Received: by mail-lf0-f72.google.com with SMTP id f194-v6sf5095583lff.6
        for <gclcip-std-proposals@m.gmane.org>; Mon, 12 Mar 2018 03:33:03 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1520850782; cv=pass;
        d=google.com; s=arc-20160816;
        b=dybeSpqJO46Qo5facSVwlpj/iDIwNngNckgKfDWYJjv+66SlQIN+7GovrWx9QXS/mQ
         Nw0TEqvgbccpE70dEajFWX2z4kYtwmcx1rCU1e+O3AiIyJEjPYrZEvbAPQLl4QR22QxU
         1UU3cts2qD3oXELn6sfn9WWHPEvVadw7txYwpMvFzVn5/jdEoljwjO2csXPIJK+Qtu1F
         v5CVIg4Kn1lQobQ+Ks1yD35To7WAuSWCmSxiN+rX54shMg2dMZMOI5wkq16n1hP/GXiT
         3ZlDJg9bqNq5+k2QT7tcBAduh3RoBU5ubBbUCyCi/k10A97QYn1PdVot1EkUxEd2mx70
         uBLA==
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:content-language
         :in-reply-to:user-agent:mime-version:references:message-id:lines
         :date:subject:from:to:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=ZhmeL6FgF1sFT0nzYqX92nDigqBeu58dvoWu36EGuEE=;
        b=ef0vMQCQnnY4kmAWQ+uE+/+IAtij1w2osHzFpvtQ5IUe8f5LN2w1dlTLvJ7sux24cO
         EVddsHwPvWMCmM88FuB+49WTPT0zm4uS4vKwpKwDhvB+nggJPNX2YODO87ZbWhlLYYVJ
         m7UT3sV7F8rPoVb/aYEDFce5jzy05QuKlrujazbb3uf0TU4IsttIlLqcFCgVtY87wmOI
         kYXySFkivWhyTqVbBGDY/q5ZR1jQPd1lvNsgNx4mi4OB5JJbUem7vg4jCE+FZCubCqkg
         k3VVulqf+gcGq9qAFXiEcedYFq2jY5HpKYAf6M8m/Fnn+fAnsOFlfH7Z/onRBWaZ7O+E
         OYvw 
ARC-Authentication-Results: i=2; mx.google.com;
       spf=neutral (google.com: 195.159.176.226 is neither permitted nor denied by best guess record for domain of gclcip-std-proposals@m.gmane.org) smtp.mailfrom=gclcip-std-proposals@m.gmane.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=to:from:subject:date:lines:message-id:references:mime-version
         :user-agent:in-reply-to:content-language: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=ZhmeL6FgF1sFT0nzYqX92nDigqBeu58dvoWu36EGuEE=;
        b=MdtjB94V7vZe/sArN+TaoRODulNgF46UIba8VMUADY812m9fOyXXKwYc6kU8ZKC7B9
         NKk24jGXSSJnKGP2TYQFvMOjUwDEuWa0cCqkjQM3zZ5/tFgXQLBmc9zM16nNKEBWVeRF
         EAVa5xbmdPoTGv7bhN0cCIaRmStzd7C71vBpfPCiZIPD/yMusRxFdGrATeoc+3X2iMpd
         8JdTENRbvuNmtDblIS5GujRucZ4j/dlefUcLecoHw7iLYESmLROYpIUPXAhE7vQMwCBd
         uykyPz617PmxSXZGe3Li8kqbAO0x3dWko3esVv/p7zdw5W28tgCCpTPxf2TxmZkakEWc
         aysA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:to:from:subject:date:lines:message-id:references
         :mime-version:user-agent:in-reply-to:content-language
         :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=ZhmeL6FgF1sFT0nzYqX92nDigqBeu58dvoWu36EGuEE=;
        b=UWwTFic8hr/3ZbKqpWAub2rGAvfDw+njX2jh0ZZn5fheVPI0zTcM2iYyEM4PWiFYBf
         4Ne3R/pM5ZU4rCOelQqsG6qCbpTUWuN/vf9RPHLql1NYfAKK3H8uH0TvSb6FDqHTOWkG
         9IztKu1fw/63Ffx07NaSt+2eOOOIc3X+H85caC2uTDkupfu7pbE2ifnAdf6buEh06J0E
         3uPJNG5ZfQ4Kk+w5e6pZvIvvEynoyX56nemJ3f6mBvI3GNSQ6HeZsVZbP/cLR8Q1H4cX
         VILJyYJ63OKnfqBpSXTX8g80Kgo2Kg9PoMb8jLuE2En/bseYfrNt1OD5+Yz+uIRtJNZl
     
X-Gm-Message-State: AElRT7Fyv2C+C8LcJU8AE81ThZrJsMYrJuhKXlMXibUd7wg0EneDyc/r
	r2WZTMrlyZfy0zQmt3hiLrY=
X-Google-Smtp-Source: AG47ELtf1xNxiNkpfDLBVJsB6WHhnsR9WhZYit5gehMCf6s1eO0regBpQtDCQs/SBc4jMCqwL4MyVg==
X-Received: by 10.46.145.150 with SMTP id f22mr415634ljg.13.1520850782881;
        Mon, 12 Mar 2018 03:33:02 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.46.23.194 with SMTP id 63ls1337259ljx.8.gmail; Mon, 12 Mar
 2018 03:33:00 -0700 (PDT)
X-Received: by 10.46.146.25 with SMTP id k25mr4554576ljg.100.1520850780782;
        Mon, 12 Mar 2018 03:33:00 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1520850780; cv=none;
        d=google.com; s=arc-20160816;
        b=rFirBwkTvvbPZh2MZqNm19ZemYB0I4UTY9r24f6JE1tDoAydWb7Q+H592QsOG2X+xz
         mYOFys2HKJ47+H3Ifj8E5ye4ihkaMgMxr/Fy/qiNYj2JzbEV3r42UvR+oc6BcYFHcQ0T
         VQdYk1sLbjNmUW8DBfsrLfd1bolHI7PnE5RJiNlR5M0MxoCKpfPNzCS0oIcdRCbOSush
         oBIZ9IBR4NbVp6mRLG1kPeJb/zSqomWw4x8CkaQHxwI67x1g7mRiwGnvk80nes9KLppU
         Ln0qMXMAE0w6PtWOHTreYWGaob/vII1mqH8fxKmteT3U2REIeVNVPN/LwleYf5Drab1i
         FUWQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-language:in-reply-to:user-agent:content-transfer-encoding
         :mime-version:references:message-id:lines:date:subject:from:to
         :arc-authentication-results;
        bh=HU8sC/tY72Ti7KtHQfLWOZmJtQ9gJt0GMNZU/ri8CyQ=;
        b=tZDcoTHlCpXkrRAx5QY7uAvXTArYUWSFE43iLGkm74mDdRl8CJ7ibTHSe0ODPm/ZT1
         nsI8dkgiPSsNUtKlTn+ZffuUU0nJiM1YuF3Rt0Ld1rCxaQuL/882HBoZgr8H2kgzA/fV
         D2+vLkHrAkmujMXXRWs4DRdQvHAbsKaHvqsZNEhuZ3OxTqObzZy+EO/TpNHZlz49qkJw
         kwplUoC2nUg9bDiYMs161WUVAXkKEdPCEhR7VvWc4vS4CgzwdWAOgo4yGXDiMTCKMIek
         bPIZ5R2mT+djdIroCiJTCNuNUFI7xoKdDoDOxqt+U+EG6mlHQYOe0IX62jTli1hYBfLx
         kz+A==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=neutral (google.com: 195.159.176.226 is neither permitted nor denied by best guess record for domain of gclcip-std-proposals@m.gmane.org) smtp.mailfrom=gclcip-std-proposals@m.gmane.org
Original-Received: from blaine.gmane.org ([195.159.176.226])
        by mx.google.com with ESMTPS id h75-v6si2699557lfe.469.2018.03.12.03.33.00
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 12 Mar 2018 03:33:00 -0700 (PDT)
Received-SPF: neutral (google.com: 195.159.176.226 is neither permitted nor denied by best guess record for domain of gclcip-std-proposals@m.gmane.org) client-ip=195.159.176.226;
Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2)
	(envelope-from <gclcip-std-proposals@m.gmane.org>)
	id 1evKjE-00080j-9z
	for std-proposals@isocpp.org; Mon, 12 Mar 2018 11:30:52 +0100
X-Injected-Via-Gmane: http://gmane.org/
Original-Lines: 38
Original-X-Complaints-To: usenet@blaine.gmane.org
In-Reply-To: <1fea07df-46a6-4df2-865a-849be8f8d129@isocpp.org>
Content-Language: en-US
X-Original-Sender: cppljevans@suddenlink.net
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 195.159.176.226 is neither permitted nor denied by best guess
 record for domain of gclcip-std-proposals@m.gmane.org) smtp.mailfrom=gclcip-std-proposals@m.gmane.org
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:37313
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/37313>

On 03/11/2018 03:38 AM, jeffersoncarpenter2@gmail.com wrote:
> Not sure how this will be received -- I haven't posted here much.  Just
> thought it would be worth mentioning this idea.
> 
> Suppose you have an API that you want to optionally allocate storage for
> your user.  They can either pass in a pointer to some existing allocated
> space, or pass in a null pointer and space is allocated for them.
> 
> void foo(int *x) {
>    if (x == nullptr) {
>      x = new int;
>    }
>    // etc.
> }
> 
> Just figured it would be a decent idea if the || operator received a
> pointer overload.  Then you could write the more succinct
> 
> void foo(int *x) {
>    x = x || new int;
> }
> 
> or even (ducks for cover)
> 
> void foo(int *x) {
>    x ||= new int;
> }
> 
> would be nice.
> 
There's precedent in another language, ruby.  An example use is:

https://github.com/tardate/pdf-reader-turtletext/blob/master/lib/pdf/reader/positional_text_receiver.rb#L16

with explanation here:

http://www.rubyinside.com/what-rubys-double-pipe-or-equals-really-does-5488.html


-- 
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/p85ksl%24tij%241%40blaine.gmane.org.

.
