220 8694 <a63b7659-74d7-465b-8f6e-69cf466cac57@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: gornishanov@gmail.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: string_view::is_null()
Date: Sun, 19 Jan 2014 10:31:58 -0800 (PST)
Lines: 107
Approved: news@gmane.org
Message-ID: <a63b7659-74d7-465b-8f6e-69cf466cac57@isocpp.org>
References: <8045a4d2-721d-4725-8bb7-7a91b6f53ec8@isocpp.org> <186E0927-C962-4E34-AED0-E7509DD1F0A0@gmail.com> <7aad44d8-6b4e-438a-b309-bd898b994b34@isocpp.org> <9C2C439F-7983-4224-B272-53CAD0E2E456@gmail.com> <CANh-dXnYg=1kmm1nJdSnTXmYyfBxbLTD9b+wecT+eZm5nPkf2A@mail.gmail.com> <CAGg_6+Pz0gQQcY_Vq6LTMFc-4iOJvVN1O3jc3gjh0J2egBTgGg@mail.gmail.com> <CANh-dX=Dr35_jvxadm2HWxNk6e87y8V+Dkyiw+syBfgfdTfobw@mail.gmail.com> <CAPOJ94O19N207rjm73tKJSc7K55kOzYxHbY9wtXquk=_uqqMsA@mail.gmail.com>
 <8E74B747-7450-41E0-8D1E-48C2D6F81535@gmail.com>
 <d17db29f-8da3-402f-834a-66b02e4d9621@isocpp.org>
 <3a3d55c0-20cb-40ff-ae46-84663d21f44d@isocpp.org>
 <dc982a9d-541c-4472-96f8-bed3327edeb0@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_401_757183.1390156318178"
X-Trace: ger.gmane.org 1390156317 27412 80.91.229.3 (19 Jan 2014 18:31:57 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sun, 19 Jan 2014 18:31:57 +0000 (UTC)
Cc: gornishanov@gmail.com
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC47RF4IW4GRBH5U6CLAKGQEF4PI43Y@isocpp.org Sun Jan 19 19:32:02 2014
Return-path: <std-proposals+bncBC47RF4IW4GRBH5U6CLAKGQEF4PI43Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yk0-f200.google.com ([209.85.160.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC47RF4IW4GRBH5U6CLAKGQEF4PI43Y@isocpp.org>)
	id 1W4xA9-0004wm-AG
	for gclcip-std-proposals@m.gmane.org; Sun, 19 Jan 2014 19:32:01 +0100
Original-Received: by mail-yk0-f200.google.com with SMTP id 200sf7740045ykr.3
        for <gclcip-std-proposals@m.gmane.org>; Sun, 19 Jan 2014 10:32:00 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:cc: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=CohEz+aE51dhZrCITxjSTkNt7hvHsHaJW8fJyi/eLq8=;
        b=vjd8BKiz0VYnNXzaK9zHgJToWeHRe0cyjwuYqm5rXF7JkOCR9OAfewiWVwWrilV9p6
         46SiVwtQGeLNshQfC9QUGNQLDr1+Dn/c8tfz13KywQutMCkzpkEJyAjbMww9tlo9JiZ7
         eW5V40RhWpTb09aVp/SkU0sB7ALHjR+RdIJYF9ufXGj7ba3WtO9tHnxCwIXSij7H8sHI
         iwa77gTih8DIdXhZZUE1S7uQ04qJ1rIp8xSvJ/0QB3StXLi5YVPOJdEA7OjiVUlY8ZVN
         Tfm5rcmW85KMriDZn8xNOl8awJsqEF18Ud4tIXBIe0uiHc0dUkcWsegjVXSsjK6TYi3V
         gv4g==
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:cc: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=CohEz+aE51dhZrCITxjSTkNt7hvHsHaJW8fJyi/eLq8=;
        b=m9ETij4B4xCcV6cXlz8ZPbEsTim1fhy/y4RFCwsE/0yr2Plfq1DL8nNIy/wrOOGUzY
         4Iz2sK835ySXeG/kDF/zSE63hZekoCltY4SOzkI9Av28xh8WgrHGR7H+atxrAUtRRFsv
         1DUL7kGxDitTXw0y59VHjEjnRjREbss3O+Zm2c04uQsQP4eku9AM6I9cmCdaK2LC7LWB
         oOJRytIuzvH7vBpb/SjFtq0HI9XQojda0idABln6jWgahnxLGCc86llsiRchz+SMRHKd
         3XjQkHhrUghB8AH2dvoHPRVEpAzTwuRkYjzOC8tCNGxTwDrxK86u/s59Re5lz97OAIAi
         oW/A==
X-Gm-Message-State: ALoCoQmFSTSJx5dAWicVQtzHwQvCH/25QIpvHmNIG51UXYWZiLfS6dN/XjvbPKN9LSNA4vagU3Th
X-Received: by 10.52.76.34 with SMTP id h2mr4436789vdw.2.1390156320461;
        Sun, 19 Jan 2014 10:32:00 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.51.15.229 with SMTP id fr5ls1309456igd.13.canary; Sun, 19 Jan
 2014 10:31:59 -0800 (PST)
X-Received: by 10.50.111.200 with SMTP id ik8mr173651igb.7.1390156319686;
        Sun, 19 Jan 2014 10:31:59 -0800 (PST)
In-Reply-To: <dc982a9d-541c-4472-96f8-bed3327edeb0@isocpp.org>
X-Original-Sender: gornishanov@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: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:8694
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/8694>

------=_Part_401_757183.1390156318178
Content-Type: text/plain; charset=UTF-8

I did not propose using unspecialized optional. I suggested to add 
specialization of optional<basic_string_view<...>> to string_view header. 
Thus any use of optional<string_view> will pick up specialized version that 
can have constructors that you desire.

I think it is beneficial to not to roll nullability into 
string_view. optional is The Way to make type nullable and where possible, 
one can use specialized optional to add additional constructors and/or 
provide more efficient implementation than default optional.


On Saturday, January 18, 2014 7:30:17 AM UTC-8, Alexander Bolz wrote:

> Am Samstag, 18. Januar 2014 00:10:41 UTC+1 schrieb gorni...@gmail.com:
>>
>> What if string_view provides a specialization for optional<string_view<>>?
>>
>> That way optional<string_view> can be implemented very efficiently by 
>> checking if sv.begin() == nullptr and does not consume any extra storage. 
>> An extra benefit is that we have clear distinction between nullable types 
>> (optional<T>) and regular types, int, vector, string_view, etc.
>>
>> Will this solution satisfy the original poster?
>>
>
> An (unspecialized) optional<string_view> is not always an option. E.g. I 
> can't simply change a function like
>
> void f(char const* s) {}
>
> to
>
> void f(optional<string_view> s) {}
>
> because I can no longer write f("hello"). So the specialization should be 
> implicitly constructible from a char array.
> And then an optional<string_view> constructed from a nullptr should be an 
> uninitialized optional since there
> are no preconditions on f, I should be able to write 
> f(getenv("not-an-env-var")).
>
>

-- 

--- 
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_401_757183.1390156318178
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>I did not propose using unspecialized optional. I sug=
gested to add specialization of optional&lt;basic_string_view&lt;...&gt;&gt=
; to string_view header. Thus any use of optional&lt;string_view&gt; will p=
ick up specialized version that can have constructors that you desire.</div=
><div><br></div><div>I think it is beneficial to not to roll nullability in=
to string_view.&nbsp;optional is The Way to make type nullable and where po=
ssible, one can use specialized optional to add additional constructors and=
/or provide more efficient implementation than default optional.</div><div>=
<br><br>On Saturday, January 18, 2014 7:30:17 AM UTC-8, Alexander Bolz wrot=
e:</div><blockquote class=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8e=
x; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-wi=
dth: 1px; border-left-style: solid;"><div dir=3D"ltr">Am Samstag, 18. Janua=
r 2014 00:10:41 UTC+1 schrieb <a>gorni...@gmail.com</a>:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; padding-left: 1ex; bor=
der-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-sty=
le: solid;"><div dir=3D"ltr"><div>What if string_view provides a specializa=
tion for optional&lt;string_view&lt;&gt;&gt;?</div><div><br></div><div>That=
 way optional&lt;string_view&gt; can be implemented very efficiently by che=
cking if sv.begin() =3D=3D nullptr and does not consume any extra storage. =
An extra benefit is that we have clear distinction between nullable types (=
optional&lt;T&gt;) and regular types, int, vector, string_view, etc.</div><=
div><br></div><div>Will this solution satisfy the original poster?<br></div=
></div></blockquote><div><br></div><div>An (unspecialized) optional&lt;stri=
ng_view&gt; is not always an option. E.g. I can't simply&nbsp;change a func=
tion like</div><div><br></div><div>void f(char const* s) {}</div><div><br><=
/div><div>to</div><div><br></div><div>void f(optional&lt;string_view&gt; s)=
 {}</div><div><br></div><div>because I can no longer write f("hello"). So t=
he specialization should be implicitly constructible from&nbsp;a char array=
..</div><div>And then an optional&lt;string_view&gt; constructed from a null=
ptr should be an uninitialized optional since there</div><div>are no precon=
ditions on f, I should be able to write f(getenv("not-an-env-var")).</div><=
div><br></div></div></blockquote></div>

<p></p>

-- <br />
&nbsp;<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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<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_401_757183.1390156318178--

.
