220 28426 <da4a8fb7-246b-f19c-3f50-7bb5f318f1a4@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 23:59:45 +0300
Lines: 38
Approved: news@gmane.org
Message-ID: <da4a8fb7-246b-f19c-3f50-7bb5f318f1a4@gmail.com>
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>
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 1475009999 32663 195.159.176.226 (27 Sep 2016 20:59:59 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 27 Sep 2016 20:59:59 +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+bncBCXY5TXHWYJRBRF3VO7QKGQEHXABIFQ@isocpp.org Tue Sep 27 22:59:55 2016
Return-path: <std-proposals+bncBCXY5TXHWYJRBRF3VO7QKGQEHXABIFQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lf0-f69.google.com ([209.85.215.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCXY5TXHWYJRBRF3VO7QKGQEHXABIFQ@isocpp.org>)
	id 1bozTf-00075K-6N
	for gclcip-std-proposals@m.gmane.org; Tue, 27 Sep 2016 22:59:47 +0200
Original-Received: by mail-lf0-f69.google.com with SMTP id b71sf25501862lfg.2
        for <gclcip-std-proposals@m.gmane.org>; Tue, 27 Sep 2016 13:59:49 -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: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=Vh2Kn1kWVJ1HUJr4c/8uTbpPmZUL5ZacH1kjPUuRIhc=;
        b=cjw/ujtjR0wkdwWsUMYaCSTY0UInGSCsPieBRV0sCwz3qsYmosKJM6G8a5cF9JxnyR
         ZXA+xYiE3ZhfolLcCV7UePoeXi1BUeLRw50d6UcOiamRg2dJjE7ee4oCzqQx9qdo6BaB
         BVsVKCgEHGPWu2wZc9aaQChcnySrsVbZFVkREnUFDYwVzcbyMe+oUoNBtWhqx7GUhBoK
         ZMBMvz5LxjYpMYcSFczbZEnE92c3uR9c1jpMjfYDPRT5jF8OwIRjupthGBF2AU+l+Zi5
         QeJ+dpi75wxNdNvCRPHCJShU/VZ7TJA/CXLL3JWFrF08w4S+ABmm4rMYiHwWIxfHHI8t
         g2ng==
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: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=Vh2Kn1kWVJ1HUJr4c/8uTbpPmZUL5ZacH1kjPUuRIhc=;
        b=S1wZAXM3Tkwz29zmCXkeI82AmAgHN65N5SRosUNY8fMumuT6cjLIPGXRDIbPMO28wH
         lD/ANKld+RBVzLr4BR5zbe4+Ykjvj6L33Rk6DrO0iwfo+5lwWku6MumHRkbZtdqRejlw
         Wy7wzEIZwS+0RLiSeTEvoosbq83jz/YQShtX4yxFFpo2YF81z4kgAgeqh5uQK7zSqy92
         HRQvKxF5B0mO/Kf8W/ZEfssthjLFqAWrrOXm0VxioaZXYvyS4lyuaw+PFRvCGsBq5rzb
         GO29lN30DITpuubHnD1u8QRrkmx4FOyv7gHJ65DxCOhgiZiWWHXUqrvSiUkbNSCRwNff
         BEDg==
X-Gm-Message-State: AE9vXwNme3eU2QwEFIrFdCWLRYK2hcvqQnLhtUvtqecuAy7BdJ2iVqVravPyw4AAlwKA0A==
X-Received: by 10.46.69.213 with SMTP id s204mr1568185lja.18.1475009989102;
        Tue, 27 Sep 2016 13:59:49 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.46.71.147 with SMTP id u141ls2258438lja.34.gmail; Tue, 27 Sep
 2016 13:59:47 -0700 (PDT)
X-Received: by 10.46.1.67 with SMTP id 64mr9830759ljb.24.1475009987695;
        Tue, 27 Sep 2016 13:59:47 -0700 (PDT)
Original-Received: from mail-lf0-x244.google.com (mail-lf0-x244.google.com. [2a00:1450:4010:c07::244])
        by mx.google.com with ESMTPS id f188si1960663lfe.266.2016.09.27.13.59.47
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 27 Sep 2016 13:59:47 -0700 (PDT)
Received-SPF: pass (google.com: domain of andrey.semashev@gmail.com designates 2a00:1450:4010:c07::244 as permitted sender) client-ip=2a00:1450:4010:c07::244;
Original-Received: by mail-lf0-x244.google.com with SMTP id s29so2332635lfg.3
        for <std-proposals@isocpp.org>; Tue, 27 Sep 2016 13:59:47 -0700 (PDT)
X-Received: by 10.25.40.83 with SMTP id o80mr11176267lfo.54.1475009987126;
        Tue, 27 Sep 2016 13:59:47 -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 b79sm716522lfh.1.2016.09.27.13.59.46
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Tue, 27 Sep 2016 13:59:46 -0700 (PDT)
In-Reply-To: <2b8591ee-3a1e-4a41-8c14-221bdc5cd1e4@isocpp.org>
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::244 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:28426
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/28426>

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.

-- 
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/da4a8fb7-246b-f19c-3f50-7bb5f318f1a4%40gmail.com.

.
