220 2368 <CAA7U3HNDqV-j9wU0fw9kBwkoD6TiSmuZZhx1JCg3CNztYVMqqA@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Olaf van der Spek <olafvdspek@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: optional<T>, one more value or two states
Date: Sun, 27 Jan 2013 22:39:27 +0100
Lines: 39
Approved: news@gmane.org
Message-ID: <CAA7U3HNDqV-j9wU0fw9kBwkoD6TiSmuZZhx1JCg3CNztYVMqqA@mail.gmail.com>
References: <CAGsORuC1ADLXgS9AZZiTo=knmhT-+9Yj+82v+b8Nq_WJpb1fOg@mail.gmail.com>
	<CAFk2RUZyZA0LLUNuVNcnibv+qBF69jMytWQL3tkp-Kp21oEU+A@mail.gmail.com>
	<CAGsORuB-Qkx-LaXj2jO4yLrwN524kiJONSg7oczkQZHYaJ6ASg@mail.gmail.com>
	<d360a952-28ae-4d57-bb20-96fd08725a0b@isocpp.org>
	<CAPXezF_JggyMaXjGS9r1EAGVu1NhQBEyGEXB8tKmVqgFfjoCeg@mail.gmail.com>
	<CALJmx62zJd_tZ=XYL7TaSkRN6432SObwH9YS87eLX-h_pMuFYQ@mail.gmail.com>
	<CAOHCbivAK0ypmMhrhJ3zKpF8BHu3h_rUNzeao-HnibJkC-qqGw@mail.gmail.com>
	<ef15483d-5665-4da3-9b79-aefd3c725e1b@isocpp.org>
	<CAOHCbithEUfm+w_06V71=hpkqGUJvqiyDFqD7fesfgLy4uUieg@mail.gmail.com>
	<2c2b9360-8e5e-422d-9b85-124bd947b004@isocpp.org>
	<123b9f65-12fd-4285-bb6c-cfee383d4552@isocpp.org>
	<CAHOE3yeF6KBBz7a1uw58oA3Shh_w0HFGiLtUGEd4ntJAKBauew@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
X-Trace: ger.gmane.org 1359322769 3821 80.91.229.3 (27 Jan 2013 21:39:29 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sun, 27 Jan 2013 21:39:29 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC5NB45SSABBBEN5S2EAKGQETAUOCXQ@isocpp.org Sun Jan 27 22:39:48 2013
Return-path: <std-proposals+bncBC5NB45SSABBBEN5S2EAKGQETAUOCXQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-we0-f199.google.com ([74.125.82.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC5NB45SSABBBEN5S2EAKGQETAUOCXQ@isocpp.org>)
	id 1TzZx6-0001L9-GR
	for gclcip-std-proposals@m.gmane.org; Sun, 27 Jan 2013 22:39:48 +0100
Original-Received: by mail-we0-f199.google.com with SMTP id t11sf1826765wey.2
        for <gclcip-std-proposals@m.gmane.org>; Sun, 27 Jan 2013 13:39:30 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-received:x-beenthere:x-received:x-received:received-spf
         :mime-version:x-received:in-reply-to:references:date:message-id
         :subject:from:to:x-original-sender:x-original-authentication-results
         :reply-to:precedence:mailing-list:list-id:x-google-group-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=C7r9c/Hbxr05DDHILWKcc48ZBYteFuKqCe8DCN7DvOk=;
        b=qSQdC392Aq++hF25pcucQykj51SrXoZlkmA82qY767moscsMBcX676HhC7vNHPDHyX
         fK3M1/Hsvp0hnl4Fn6fGtPwAXvpk+0ykMODPSIxsYTuX9KhFjlXgrdzwbtV6TFTOGbwR
         RzBszDt+pmU17nMrlAa2efNemN2JZoT3iS0kPNJrLsBIGJ6T2DO6/1yZfjPsd3veyqME
         hIoU+lIWl9PFIatJhAsQ2s7okvXIn1ZplBfuy3GDstWqmnWH+CjOTG4WCNJ+5l/sXnHY
         /MAH2W6NZd3MTYSTunoQhZUE+IJv0Kkw33YyEXCnHlMzJfHH2 
X-Received: by 10.152.105.40 with SMTP id gj8mr2823058lab.9.1359322770554;
        Sun, 27 Jan 2013 13:39:30 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.152.128.164 with SMTP id np4ls46234lab.78.gmail; Sun, 27 Jan
 2013 13:39:27 -0800 (PST)
X-Received: by 10.152.111.102 with SMTP id ih6mr11192861lab.20.1359322767965;
        Sun, 27 Jan 2013 13:39:27 -0800 (PST)
X-Received: by 10.152.111.102 with SMTP id ih6mr11192860lab.20.1359322767952;
        Sun, 27 Jan 2013 13:39:27 -0800 (PST)
Original-Received: from mail-lb0-f176.google.com (mail-lb0-f176.google.com [209.85.217.176])
        by mx.google.com with ESMTPS id tv7si3651624lab.251.2013.01.27.13.39.27
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Sun, 27 Jan 2013 13:39:27 -0800 (PST)
Received-SPF: pass (google.com: domain of olafvdspek@gmail.com designates 209.85.217.176 as permitted sender) client-ip=209.85.217.176;
Original-Received: by mail-lb0-f176.google.com with SMTP id s4so3050765lbc.7
        for <std-proposals@isocpp.org>; Sun, 27 Jan 2013 13:39:27 -0800 (PST)
X-Received: by 10.152.136.20 with SMTP id pw20mr11100720lab.16.1359322767717;
 Sun, 27 Jan 2013 13:39:27 -0800 (PST)
Original-Received: by 10.152.19.168 with HTTP; Sun, 27 Jan 2013 13:39:27 -0800 (PST)
In-Reply-To: <CAHOE3yeF6KBBz7a1uw58oA3Shh_w0HFGiLtUGEd4ntJAKBauew@mail.gmail.com>
X-Original-Sender: olafvdspek@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of olafvdspek@gmail.com designates 209.85.217.176 as permitted sender)
 smtp.mail=olafvdspek@gmail.com;       dkim=pass header.i=@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?hl=en>,
 <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?hl=en&topic=25838>,
 <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:2368
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/2368>

On Sun, Jan 27, 2013 at 9:27 PM, Daniel James <dnljms@gmail.com> wrote:
> But it could easily be changed to meet them. 'Optional' is a container
> (in the wider sense) with a maximum of 1 element. It is not in any
> sense a pointer. In fact, std::optional probably should meet the basic
> container requirements, as it would allow it to be used with generic
> functions.

It's a bit like static_vector with max_size 1, true. Though I'm not
sure what supporting a container interface really buys you.

>>  I think using operator* is natural.
>
> But it does currently imply certain semantics. The current situation
> is that if you write:
>
>     auto x = y;
>     *x = 2;
>
> Then for any standard type this is equivalent to assigning '2' to
> whatever y points to. By using 'operator*' in std::optional, the
> semantics of 'operator*' will be changed. That shouldn't be done
> lightly, especially since with templates and 'auto' a type is defined
> by the functions and operators that it supports..

Isn't that more of a problem with the constructor than with operator*?

-- 
Olaf

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To post to this group, send email to std-proposals@isocpp.org.
To unsubscribe from this group, send email to std-proposals+unsubscribe@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



.
