220 35111 <a82f7b048d91673203c75fa04e98f481@kdab.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Marc Mutz <marc.mutz@kdab.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Marking more std::string_view members noexcept
Date: Thu, 26 Oct 2017 10:55:04 +0200
Organization: KDAB
Lines: 67
Approved: news@gmane.org
Message-ID: <a82f7b048d91673203c75fa04e98f481@kdab.com>
References: <3d03cd7d-2177-98fd-408d-f74b1f6a8552@gmail.com>
 <5005582.pCRZNEiGFO@tjmaciei-mobl1>
 <CAGg_6+M1gvNh82YX6x4Nr3=rFSPW973nmumTF0SkyMJ7c2Yoew@mail.gmail.com>
 <3446274.dRsjijLxpX@tjmaciei-mobl1>
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 1509008119 30361 195.159.176.226 (26 Oct 2017 08:55:19 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 26 Oct 2017 08:55:19 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCRPXDOU7ECRB4OFY3HQKGQEB6KNNZI@isocpp.org Thu Oct 26 10:55:15 2017
Return-path: <std-proposals+bncBCRPXDOU7ECRB4OFY3HQKGQEB6KNNZI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wm0-f69.google.com ([74.125.82.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCRPXDOU7ECRB4OFY3HQKGQEB6KNNZI@isocpp.org>)
	id 1e7dwQ-0006ST-IZ
	for gclcip-std-proposals@m.gmane.org; Thu, 26 Oct 2017 10:55:06 +0200
Original-Received: by mail-wm0-f69.google.com with SMTP id v127sf1515592wma.3
        for <gclcip-std-proposals@m.gmane.org>; Thu, 26 Oct 2017 01:55:14 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1509008114; cv=pass;
        d=google.com; s=arc-20160816;
        b=ZLG47gMVOa/ZJ0awSj9jqF2ECAX1h3KlwGeEhVJ0E9PpgWHa4rQ2pWp67CtXgO5phP
         bnhA0fgfO8cY2Z1zSpEw64I3SWg2Os2X2qC+yYAb2Tmpo7eEdnFt8dECrA1YuSlNt2zc
         dqP53+5kYmtaPeyQ5yhFRlfiBTWw/CstTHp4cGGpBPCEJ2UkJvI3ogPI9REyyloB7zNN
         5kw2SzSAQnY+NXQbPCQ/gWLh9aUbLSLRS+/7NXogxS7BTwOmZpJjyzbhNQ8USuCZ3eO8
         +Jno3u3OHe87nZirNybzITlaoXwUShkDfuzLMNCZeTJeyMjd9Ia7vV3eYWDxWXjkga7f
         ZBfg==
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:message-id:references
         :in-reply-to:organization:subject:to:from:date:mime-version
         :arc-authentication-results:arc-message-signature:dkim-signature
         :arc-authentication-results;
        bh=oD1M7XpWQSedHFksKRBGpZgCMmueFxZ2FtjVumWiBZ4=;
        b=ig5hP7OIQDaJr9yxTiX2wpi8JiQGDvtCUCh+TfPyA+zEmmTcRwUeN/GWAzzDkjUJsP
         qE/mvLkBTalLBN9MYdq6Yi/6cwBNUwLbiFRxJlGae+uWZ7XG6wqxvt33XJxjLtBIK+QP
         pXlgeYF7Ru/PXZ1fyjFthRxe6Wtyet/k3Li62SN7hE4ENi13FVPT1aZezVeGMfzZyACW
         /Y0xI9dqllIZ/v+vN9kh0WbhIIjYwsib9/ybW/LgMfgV4YSaQmkdYCh2RNNphQ85lUu1
         H/mfl2bJUb5ftp6KJvy/LWAzxbCQrrX0mWEXYLgU9uTvQVs834lFshw4Lo51ti1q844o
         SOqA==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of marc.mutz@kdab.com designates 176.9.126.58 as permitted sender) smtp.mailfrom=marc.mutz@kdab.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:date:from:to:subject:organization:in-reply-to
         :references:message-id: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=oD1M7XpWQSedHFksKRBGpZgCMmueFxZ2FtjVumWiBZ4=;
        b=jhHM4NSWLDvuRWBS8dhcddyg5g6e0k0dKvYihN1acukn5z3/euFPIpkemjaDmfyJOA
         ztZbI/o3Z573WQyeBowtCUnZN1nnvwVY6cGuLq2o1N/cQUz8UjlKS0qHBXtEd/zqO6jw
         i+fokY8IvJZvMnIeGISNnm2Fouc4mFb0W4YOS/3TFp7hQmagrM3CDMz8b9D+BslwtgkZ
         eqMck8tWp1Xfi4ThtOIRMqtckpMa+s5gBKtKaeCxbq+pmOjss5gvIcD1O6Crj0eodUDb
         r1mxnjcxcGilfhNa48w/xzxKB+3tpfE2J2TYN24bYpirlP8/5hF4/BTR0hcS+hfQVGPO
         3KsA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:date:from:to:subject:organization
         :in-reply-to:references:message-id: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=oD1M7XpWQSedHFksKRBGpZgCMmueFxZ2FtjVumWiBZ4=;
        b=sFyp9HpxU2o02FuaVJhDRgG9OYNa+Z377vOw9lik9Sx5KcXGNccZ2h6P8vidTUBLn7
         oGI/K0eKOg3+s9U3RbB8Rl6sGxEZQWTHyUeGdU23K+uGx3hrqXy4PY8ewv730dHi3ilB
         yBgsCguAWxDt3ZqsR7wMUU2uZGIzRfJf1ItzPWvn5R6G/VbhWJLB7Uz6cwO9kBI2nIxB
         cIBfZiJH3W6E/6hFFsFuMO6OwDtrq2+4nz5Pf4tKQidVtnZxfdfF/tzBuZdudCy7TtmU
         E+WiKsN38b94FFewfyNujwQmkuklLHFHYo79i0TBgAfK7xLM+kCDwwW9QurymvCRRLeo
         QJIw==
X-Gm-Message-State: AMCzsaU9F8CSVU7tC+UqddjpPbIWdZFLXi2spQzTAhENiuXbkarTX0Nk
	Map2RncBn8bSR5W2XcW6+4K++g==
X-Google-Smtp-Source: ABhQp+Q2P3iAKlHSN8tshgb6zZgHMYHYlpTKrKje/3arIjmGPRzprbAu1ueeYj3lWjG1HUzfHBoilg==
X-Received: by 10.28.184.138 with SMTP id i132mr128410wmf.30.1509008114282;
        Thu, 26 Oct 2017 01:55:14 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.10.83 with SMTP id 80ls1260669wmk.1.canary-gmail; Thu, 26
 Oct 2017 01:55:12 -0700 (PDT)
X-Received: by 10.28.173.66 with SMTP id w63mr919707wme.17.1509008112846;
        Thu, 26 Oct 2017 01:55:12 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1509008112; cv=none;
        d=google.com; s=arc-20160816;
        b=ZY9QC6ts8P62gfsCIn3TqlYL7xwK8/xBTRWBORJpRfVQBAsWcTvx/uOA80BFcPdqBu
         xbVwmPstVNj7aOG6JS5MdSTuL5JcOOsl6E0tqBpsPqHTZEBIpWzEUJSF8LTsmEkCO5h5
         Qab+D4SrmvZD9M+lhurl/us0/dZhEhvfrUiTldywQxgEsq24djZpMejf3+Ushvgxd1cj
         Oe0INdFGg0SldHtVR7zSC7BzvYQyrz9VmL4cwjrSImJRWNm0E02o+bEi/fXyHJOWgdes
         HrllkrsFbyS9B8DHdnvgp08JwGAexezyTYJMDSl243x6JM0BTCJe31yA/5M4wQmllR+S
         UznA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=message-id:references:in-reply-to:organization:subject:to:from:date
         :content-transfer-encoding:mime-version:arc-authentication-results;
        bh=72dbEhchOEnaLKKAZ0LwadNVmNmYT9673AW37NvI/n0=;
        b=c21VnJvPM2qJTmMCQOBSJtI4ULZ3HXDnCwSmzUZCp7tcsA8ZwAcwKOhsFy5mhP0xOk
         ek8Dkfvuu/KOXm3hbCPTr1N8T+yFPckZfirPxsCahsG90H1zZq/k9sw2Hf8srUZyZbgo
         r3NS6gqHlNsuhM6PvPqr14BKzpyVErtUbZX2jiDralvgK8pn3ATRLYHnDBhhStI7eBUl
         lOSzaiSDP93i/OHHGA2214/aHHepO3sc6MkvjE2exP1x4OIaki3pgYY/KM44/KP3d2XP
         AgO+eecfLMU/R9MThyjxB9ilG3LkCjK/VGP9UOOs8n2pgOFsFBm7HanljJe79iD/4kbR
         R62g==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of marc.mutz@kdab.com designates 176.9.126.58 as permitted sender) smtp.mailfrom=marc.mutz@kdab.com
Original-Received: from mail.kdab.com (mail.kdab.com. [176.9.126.58])
        by mx.google.com with ESMTPS id d197si710999wme.168.2017.10.26.01.55.12
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Thu, 26 Oct 2017 01:55:12 -0700 (PDT)
Received-SPF: pass (google.com: domain of marc.mutz@kdab.com designates 176.9.126.58 as permitted sender) client-ip=176.9.126.58;
X-Virus-Scanned: amavisd-new at kdab.com
In-Reply-To: <3446274.dRsjijLxpX@tjmaciei-mobl1>
X-Sender: marc.mutz@kdab.com
X-Original-Sender: marc.mutz@kdab.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of marc.mutz@kdab.com designates 176.9.126.58 as permitted sender) smtp.mailfrom=marc.mutz@kdab.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: <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:35111
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/35111>

On 2017-10-26 05:04, Thiago Macieira wrote:
> On Wednesday, 25 October 2017 19:30:21 PDT Nevin Liber wrote:
>> > QStringView has both a pointer and an array constructor. That means:
>> >         const char16_t str[] = u"Hello\0World";
>> >
>> >         QStringView(str).size() == 11   // constexpr
>> >         QStringView(+str).size() == 5   // not constexpr
>> 
>> I'm not sure what constexpr has to do with it.  Isn't it array vs. 
>> pointer
>> that matters?
> 
> Just a dig at the inability to overload on constexprness.

In QStringView, it's just an optimisation, because...

> Calculating the length of char16_t(&)[N] is easy: N - 1.

.... this is C++11-constexpr (which we still need to care for, in Qt) 
while ...

> Calculating the length of char16_t* can't be done in a constexpr way.

.... is only C++14-constexpr (well, if you want to support reasonably 
long strings, otherwise you could come up with a recursive 
implementation).

We should probably document that the QStringView array ctor has the 
precondition that it contains no embedded NULs, but it seems qdoc is too 
clever for it's own good: 
https://doc-snapshots.qt.io/qt5-5.10/qstringview.html doesn't have the 
docs for the array ctor.

>> It also means
>> 
>> QStringView(b ? u"Hello\0World" : u"Howdy\0World") has subtly 
>> different
>> behavior than QStringView(b ? u"Hello\0World" : u"Goodbye\0World"), 
>> doesn't
>> it?
> 
> Uh... I don't know. godbolting to the rescue...
> 
> Why does this call the pointer version?
> template <unsigned N> void f(const char (&)[N]);
> void f(const char *);
> 
> void g(bool b)
> {
> 	const char str[] = "World";
> 	f(str);
> }

Because ordinary functions are preferred over templates. You need 
constrained templates to overload on pointer vs. array: 
https://www.kdab.com/qstringview-diaries-masters-overloads/ (can't seem 
to link to a section, C-F for 'third').

Thanks,
Marc

-- 
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/a82f7b048d91673203c75fa04e98f481%40kdab.com.

.
