220 28428 <0574ad73-0d36-47c0-9e47-79e234cc6708@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Edward Catmur <ed@catmur.co.uk>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Marking more std::string_view members noexcept
Date: Tue, 27 Sep 2016 15:52:46 -0700 (PDT)
Lines: 48
Approved: news@gmane.org
Message-ID: <0574ad73-0d36-47c0-9e47-79e234cc6708@isocpp.org>
References: <3d03cd7d-2177-98fd-408d-f74b1f6a8552@gmail.com>
 <CAGNvRgBSk47UXuzh_jm_Yr2pBCM5NYSZ8kqVjwLyWsm-4r6ozw@mail.gmail.com>
 <af89c375-0437-4092-cfc7-d93eafbf969e@gmail.com>
 <2b8591ee-3a1e-4a41-8c14-221bdc5cd1e4@isocpp.org>
 <da4a8fb7-246b-f19c-3f50-7bb5f318f1a4@gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2996_946260890.1475016766678"
X-Trace: blaine.gmane.org 1475016778 24297 195.159.176.226 (27 Sep 2016 22:52:58 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 27 Sep 2016 22:52:58 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDZLZTXF7UJBBP7QVO7QKGQEPPDJCAQ@isocpp.org Wed Sep 28 00:52:54 2016
Return-path: <std-proposals+bncBDZLZTXF7UJBBP7QVO7QKGQEPPDJCAQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-it0-f69.google.com ([209.85.214.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDZLZTXF7UJBBP7QVO7QKGQEPPDJCAQ@isocpp.org>)
	id 1bp1F1-00056y-GV
	for gclcip-std-proposals@m.gmane.org; Wed, 28 Sep 2016 00:52:47 +0200
Original-Received: by mail-it0-f69.google.com with SMTP id j69sf64961323itb.1
        for <gclcip-std-proposals@m.gmane.org>; Tue, 27 Sep 2016 15:52:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=/drpUSnhORY62UcfLe+I12y8GhyU9lCP88okTwEWKlQ=;
        b=UAQbiSFbolaIOHcL8HNn6IYcU+yiWO5ZykDdhIc/vSaiRktpnHqy4W4XI99hiR+vbb
         MLW45zpqYpP68TkHrzc30rEICYkct3/McOvTfgVGq8LvGoCBzWCGrAbaOqhkvu38Kyzj
         wkrRAHIqXgfzjpp4yVKPC/Bhm8RPFreoGb62qr2W5tOJ/ViGgoY+YM9SuuVTUxKacjYD
         bHdVx9S/rR2RUQICnV4lshyPc4q7YuULHIMPCZZN7wAunsm1UQeh26yf9BkqilzYaZ1+
         oRhd99DjLLEPnIobX9xAaRIHscTzeWDxa7gEo1EK+rdio+XeeJsO3qRH1YM0mK4YSU/Q
         HaHw==
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:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe;
        bh=/drpUSnhORY62UcfLe+I12y8GhyU9lCP88okTwEWKlQ=;
        b=kd+/eZdeqhOevtymQmE99DnwUHwpnHWlyNmHEdf1RCRcjmbuHyMMclJNZxS08GzYtv
         z1omwI0OXClDBKSJM4VBBpp5no35fJoNa5cPFs7tnuH5j+tduwgfzCEbkbrhIadKQ0V5
         W1EleRP49DWbmsEWhGhTCcL3koozdwG/QpcSZoRXglbo8qRv1YjOG2wdbv8LnlvBBxa2
         t2JLhdlW4Kvmod/K1WGrpcaUVEM2m4dqrGEeP1cxZX7SHVzC1ZYZrDWBeyCatHk6n0Uc
         KuNe45v8R+wrREb9+qdGXJPmEZ01U50dcZBYHGDN80TGTrBP1Dlt7hDVbir9ihDFfD6z
         HmEA==
X-Gm-Message-State: AA6/9Rm8ajhlWjEJ+Yynagv/M0NYTM0heCGawuO2Hqp5yiSmv/im4Y1EpoxfRom+/k1+2Q==
X-Received: by 10.36.242.129 with SMTP id j123mr1706456ith.36.1475016769077;
        Tue, 27 Sep 2016 15:52:49 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.106.72 with SMTP id l69ls1539784itc.16.gmail; Tue, 27 Sep
 2016 15:52:47 -0700 (PDT)
X-Received: by 10.36.217.2 with SMTP id p2mr384192itg.5.1475016767699;
        Tue, 27 Sep 2016 15:52:47 -0700 (PDT)
In-Reply-To: <da4a8fb7-246b-f19c-3f50-7bb5f318f1a4@gmail.com>
X-Original-Sender: ed@catmur.co.uk
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:28428
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/28428>

------=_Part_2996_946260890.1475016766678
Content-Type: text/plain; charset=UTF-8

On Tuesday, 27 September 2016 21:59:49 UTC+1, Andrey Semashev  wrote:
> On 09/27/16 23:42, Nicol Bolas wrote:
> >
> > On Tuesday, September 27, 2016 at 2:24:48 PM UTC-4, Andrey Semashev wrote:
> >
> >     Still, it feels wrong that functions that you never expect to
> >     throw are not marked noexcept. When you write non-throwing code you
> >     would look at the functions your code calls and not seeing noexcept
> >     there immediately throws a red flag.
> >
> > I believe the point is that it /shouldn't/ "throw a red flag". This is a
> > matter of simple practicality.
> >
> > C API functions cannot throw exceptions, but they equally are incapable
> > of being marked `noexcept`. C++ libraries written before C++11 will not
> > have non-throwing functions marked `noexcept`. And many C++ libraries
> > even post-11 don't rigidly mark every non-throwing function as `noexcept`.
> >
> > At the end of the day, C++ programmers cannot in general assume that
> > every function not marked `noexcept` is a throwing function.
> 
> That is true. But if one really wants to rely on such function in a 
> non-throwing code, he would have to inspect its implementation or rely 
> on documentation stating it won't throw. C functions (i.e. the ones that 
> are declared extern "C") are not a problem in this respect as they 
> implicitly never throw.
> 
> What I'm saying is that yes, you can use unmarked functions, but it 
> entails more cost on you and is more fragile (what if the function 
> starts to throw at some point in the future?) While by simply marking 
> the function you can remove that cost and make the no-throw guarantee 
> part of the interface.

It is intentional that the function might start to throw in the future, or at least in certain compilation modes. A high quality implementation might well throw from front() called on an empty string_view when built in debug mode. 

noexcept is properly reserved for functions that have no preconditions, or where throwing would never be an appropriate reaction to precondition violation. 

-- 
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/0574ad73-0d36-47c0-9e47-79e234cc6708%40isocpp.org.

------=_Part_2996_946260890.1475016766678--

.
