220 28423 <af89c375-0437-4092-cfc7-d93eafbf969e@gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Andrey Semashev <andrey.semashev@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Marking more std::string_view members noexcept
Date: Tue, 27 Sep 2016 21:24:44 +0300
Lines: 55
Approved: news@gmane.org
Message-ID: <af89c375-0437-4092-cfc7-d93eafbf969e@gmail.com>
References: <3d03cd7d-2177-98fd-408d-f74b1f6a8552@gmail.com>
 <CAGNvRgBSk47UXuzh_jm_Yr2pBCM5NYSZ8kqVjwLyWsm-4r6ozw@mail.gmail.com>
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
Content-Transfer-Encoding: quoted-printable
X-Trace: blaine.gmane.org 1475000700 20065 195.159.176.226 (27 Sep 2016 18:25:00 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 27 Sep 2016 18:25:00 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
 Thunderbird/45.3.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCXY5TXHWYJRB3XSVK7QKGQELTBD7PI@isocpp.org Tue Sep 27 20:24:56 2016
Return-path: <std-proposals+bncBCXY5TXHWYJRB3XSVK7QKGQELTBD7PI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wm0-f72.google.com ([74.125.82.72])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCXY5TXHWYJRB3XSVK7QKGQELTBD7PI@isocpp.org>)
	id 1box3e-0003p9-FZ
	for gclcip-std-proposals@m.gmane.org; Tue, 27 Sep 2016 20:24:46 +0200
Original-Received: by mail-wm0-f72.google.com with SMTP id w84sf16160676wmg.1
        for <gclcip-std-proposals@m.gmane.org>; Tue, 27 Sep 2016 11:24:48 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:from:message-id:date:user-agent:mime-version
         :in-reply-to:content-transfer-encoding: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=t9EkczRL7nL8gIxsuK5PUktv0GoiRZwHStYvyUA1J9Y=;
        b=KJul57Dqny7Da8c6yiBBQiNZf9xEESPBa6rMr8VMkKiomNShosuPzXeihyUb1QGPiQ
         FokH4zTsknVJIICKE81BWC5cw960Gmk+0TMb8LSjoPl0LRa5GCQmubN6VGUWzQ24ZUrL
         PSQiUP7DxeoB3q+b9fD341DSq3G8XzGmUGDskoEfW2cBaTc2kSSWbr4m4DJkok0hr1ro
         y/1SNU1r6XLe5/C4QDrahXGM5gld1CQcYy7NQlPBb0DPK+GBdS0XqQGMqfRZYs6sGUto
         ighnBsin0so3VmSvfHR7dkeZlyR6IBw1QUpzavuW/vz97NFcXFEFxKpgPpJjRGTvjdav
      
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:subject:to:references:from:message-id:date
         :user-agent:mime-version:in-reply-to:content-transfer-encoding
         :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=t9EkczRL7nL8gIxsuK5PUktv0GoiRZwHStYvyUA1J9Y=;
        b=FfUaS1C39QT8pLDtOcfcLcXJvMmYrfrj8Yf/wxDkW/7idhXE5y+3TLwGfzRwzw86lq
         gU7WDjvnafOzFv/FgDn5jZO0F5EcPpBWxxO6VvPjq3OAYzQzKIve5UyLOy9aPN3PQYzF
         Eqi73k6DdwZlzhWF5nE91lMvC9HT6F2E5xpdVWNmQhGt3AGTQ3qw6NeBFBImTLKPZh+7
         t6fCprorlrC5/Ja6pOP4hFfbv80XyGt9viwbhxT553nOjEgIUt9YTsuxXYqAN7NexvRy
         kv77x9+2h2diV6Z2fkdwk6vzCSr+Xe6Npl3RZTIWOnOZrkuGKV5Ft8ntL1PITGrkgVmL
  
X-Gm-Message-State: AA6/9Rk+R6oLN8ljbR6LOYwZmf8YsWycJROD61xmufiyE92K+ndB9M57BDhyFVUnFIA1Qw==
X-Received: by 10.28.208.141 with SMTP id h135mr343541wmg.3.1475000687865;
        Tue, 27 Sep 2016 11:24:47 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.25.25.206 with SMTP id 197ls622102lfz.13.gmail; Tue, 27 Sep
 2016 11:24:46 -0700 (PDT)
X-Received: by 10.46.33.77 with SMTP id h74mr6993349ljh.57.1475000686202;
        Tue, 27 Sep 2016 11:24:46 -0700 (PDT)
Original-Received: from mail-lf0-x22b.google.com (mail-lf0-x22b.google.com. [2a00:1450:4010:c07::22b])
        by mx.google.com with ESMTPS id k80si763082lfi.216.2016.09.27.11.24.46
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 27 Sep 2016 11:24:46 -0700 (PDT)
Received-SPF: pass (google.com: domain of andrey.semashev@gmail.com designates 2a00:1450:4010:c07::22b as permitted sender) client-ip=2a00:1450:4010:c07::22b;
Original-Received: by mail-lf0-x22b.google.com with SMTP id l131so31894695lfl.2
        for <std-proposals@isocpp.org>; Tue, 27 Sep 2016 11:24:46 -0700 (PDT)
X-Received: by 10.46.32.5 with SMTP id g5mr1152464ljg.55.1475000685510;
        Tue, 27 Sep 2016 11:24:45 -0700 (PDT)
Original-Received: from [192.168.1.2] (broadband-90-154-68-136.nationalcablenetworks.ru. [90.154.68.136])
        by smtp.googlemail.com with ESMTPSA id z139sm640077lff.16.2016.09.27.11.24.44
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 27 Sep 2016 11:24:44 -0700 (PDT)
In-Reply-To: <CAGNvRgBSk47UXuzh_jm_Yr2pBCM5NYSZ8kqVjwLyWsm-4r6ozw@mail.gmail.com>
X-Original-Sender: andrey.semashev@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 andrey.semashev@gmail.com designates 2a00:1450:4010:c07::22b as permitted
 sender) smtp.mailfrom=andrey.semashev@gmail.com;       dmarc=pass (p=NONE
 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-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:28423
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/28423>

On 09/27/16 20:47, Daniel Kr=C3=BCgler wrote:
> 2016-09-27 14:21 GMT+02:00 Andrey Semashev <andrey.semashev@gmail.com>:
>> Hi,
>>
>> I'm looking at string_view interface definition in N4606 and wondering w=
hy
>> so many members are not marked noexcept? For example, these constructors=
:
>>
>>   constexpr basic_string_view(const charT* str);
>>   constexpr basic_string_view(const charT* str, size_type len);
>>
>> Assuming that the input string is not a constant expression, the first
>> constructor would call an equivalent of strlen(str), which in 99% is a
>> no-throw operation. Why not mark it
>> "noexcept(noexcept(traits::length(str))"? The second constructor does no=
t
>> even need that and could be simply noexcept.
>>
>> I'm most interested in constructors, but other members like operator[],
>> front(), back(), substr(), compare() also don't seem to need to ever thr=
ow,
>> yet they are not marked noexcept.
>>
>> Is there a reason for these omissions?
>
> This is so, because these functions have a narrow contract. The
> current guideline for LWG was described by this proposal:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3279.pdf

I see. Still, it feels wrong that functions that you never expect to=20
throw are not marked noexcept. When you write non-throwing code you=20
would look at the functions your code calls and not seeing noexcept=20
there immediately throws a red flag.

>> Also, why there is no obvious constructor from basic_string?
>
> Which one in particular is in your mind?

I was thinking of "basic_string_view(basic_string const&)", but Nevin=20
already pointed me to p0254r2 and I can see there is a conversion=20
operator in basic_string instead. This looks like a very reasonable=20
solution.

--=20
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 e=
mail 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/af89c375-0437-4092-cfc7-d93eafbf969e%40gmail.com=
..

.
