220 4520 <e190fafe-c89f-4394-ab07-6856e8025e24@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: =?UTF-8?Q?Andrzej_Krzemie=C5=84ski?= <akrzemi1@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: contract programming :: preconditions in STD
Date: Fri, 24 May 2013 06:37:09 -0700 (PDT)
Lines: 742
Approved: news@gmane.org
Message-ID: <e190fafe-c89f-4394-ab07-6856e8025e24@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_49_30658112.1369402629855"
X-Trace: ger.gmane.org 1369402632 24081 80.91.229.3 (24 May 2013 13:37:12 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 24 May 2013 13:37:12 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDT2DGOJ34DBBB627WGAKGQELVQ45GY@isocpp.org Fri May 24 15:37:13 2013
Return-path: <std-proposals+bncBDT2DGOJ34DBBB627WGAKGQELVQ45GY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qc0-f198.google.com ([209.85.216.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDT2DGOJ34DBBB627WGAKGQELVQ45GY@isocpp.org>)
	id 1UfsBE-00066H-Gt
	for gclcip-std-proposals@m.gmane.org; Fri, 24 May 2013 15:37:12 +0200
Original-Received: by mail-qc0-f198.google.com with SMTP id k14sf5600826qcv.5
        for <gclcip-std-proposals@m.gmane.org>; Fri, 24 May 2013 06:37:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-beenthere:date:from:to:message-id:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :x-google-group-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe:content-type;
        bh=ZCpGujYAmJbkrLTFM8VwR2aYbzoWOw98xvF5jYdyXwE=;
        b=xEbAw1hdWM1U8NVr7pHTre2kMaT+LVmP/Ewr8qnt7p4Uvj+iY3D5Sz399GPXi5+H8v
         4RHgHDOFLfZZzwyppptP10VcLh+8ofE5X8PBWmPlTs/Zo7UvEowOZrofXZ5lP+JFUOzz
         Y8YrcYJwEYXf9WBuBys+fniGPFtIeEhqLtR7+fUdGk06Eov35penrRaWdSU/Y1PN6G3W
         GrQ1NewuzO3xa9uxl4MGI41mOcRKHiTbviI1rDi4dNvcyAaAlY8GOLPVMPOyfH2+GkfM
         4S/mQ1RA64ATDZbIpERhIzxgRqWEThWr1zhbNMVFUAb/oxlwUivu9xzFpTcJ0rP48jYO
         WjRQ==
X-Received: by 10.236.15.34 with SMTP id e22mr7918715yhe.16.1369402631669;
        Fri, 24 May 2013 06:37:11 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.0.113 with SMTP id 17ls1529056qed.28.gmail; Fri, 24 May
 2013 06:37:10 -0700 (PDT)
X-Received: by 10.49.1.197 with SMTP id 5mr1675601qeo.24.1369402630231;
        Fri, 24 May 2013 06:37:10 -0700 (PDT)
X-Original-Sender: akrzemi1@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?hl=en>,
 <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?hl=en&topic=25838>,
 <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:4520
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/4520>

------=_Part_49_30658112.1369402629855
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

Hi everyone,

While trying to figure out what should the definition of "precondition" be=
=20
in C++, I collected a number of examples of potential preconditions, and=20
things that could be confused with preconditions, from the Standard=20
Library. These could serve as a basis for choosing the semantics of=20
preconditions. If you can think of any other kind of expectations on=20
function inputs that could possibly qualify for preconditions, please let=
=20
me know.

Regards,
&rzej


UB for performance reasons

21.4.5 (basic_string element access), paragraphs 1 and 3 :

    reference operator[](size_type pos);

    Requires: pos <=3D size().

    Throws: Nothing.

To guarantee the maximum run-time performance we require of the callers=20
that they make sure the precondition holds. Somewhat similar example:

25.4.3.4 (binary_search), paragraph 1:

template<class ForwardIterator, class T, class Compare>

bool binary_search(ForwardIterator first, ForwardIterator last,

                  const T& value, Compare comp);

Requires: The elements e of [first,last) are partitioned with respect to=20
the expressions comp(e, value) and !comp(value, e). Also, for all elements =
eof[first, last),=20
comp(e, value) implies !comp(value, e).

Here, most of the requirement could be expressed with C++ expressions=20
(using C++14 polymorphic lambdas):

    is_partitioned(first, last, [&value](auto&& e){

return comp(e, value);

});

is_partitioned(first, last, [&value](auto&& e){

return !comp(value, e);

});

all_of(first, last, [&value](auto&& e){

    return !comp(e, value) || !comp(value, e); // antisymmetry

});

However, the runtime complexity of binary_search is O(log(n)) while the=20
complexity of the precondition is O(n).=20

However, there is also one implied precondition that cannot be easily=20
expressed: first and last must form a valid range. That is, there is no=20
expression that can return true for all valid ranges and false for all=20
invalid ranges. This is somewhat similar to checking if a non-null pointer=
=20
points to valid memory.
=93Logical=94 error with guaranteed error report

21.4.5 (basic_string element access), paragraphs 5 - 6:

reference at(size_type pos);

Requires: pos < size()

Throws: out_of_range if pos >=3D size().

This is accompanied by the controversial requirement from the standard=20
(17.6.4.11): =93Violation of the preconditions specified in a function=92s=
=20
Requires: paragraph results in undefined behavior

unless the function=92s Throws: paragraph specifies throwing an exception=
=20
when the precondition is violated.=94

Here, it is very well defined what happens in case we provide the=20
out-of-range index. This makes the following program well defined:

void listChars(string const& s)

{

int i =3D 0;

try {

while(true) cout << vec.at(i++);

}

catch(out_of_range const&) {}

}

The question is, why call out-of-range a =93precondition=94 if we accept it=
 as=20
well-defined input? What is the definition of a precondition? What is the=
=20
purpose of specifying one? Is it a license to the compiler for rejecting=20
any code where it can prove that a precondition is violated? So should=20
smart compilers be allowed to reject functions like listChars above? Or is=
=20
precondition only a hint on usage for other developers?
Only an irregular input

20.8.11.2.4 (function invocation), paragraphs 1 and 3:

    R operator()(ArgTypes... args) const;

Effects: INVOKE(f, std::forward<ArgTypes>(args)..., R), where f is the=20
target object of *this.

Throws: bad_function_call if !*this; otherwise, any exception thrown by the=
=20
wrapped callable object.

23.2.3 (Sequence containers), paragraph 17:

=93The member function at() provides bounds-checked access to container=20
elements. at() throws out_of_range if n >=3D a.size().=94

In either case no precondition is specified, although we can intuitively=20
see that such inputs are =93fishy=94. Thus the following code is perfectly=
=20
valid:

int process(function<int(int)> f, int i)

{

try {

 return f(i);

}

catch(bad_function_call const&) {

    return 0;

}
}

--=20

---=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/?hl=3Den.



------=_Part_49_30658112.1369402629855
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

<h2 dir=3D"ltr" style=3D"line-height:1.15;margin-top:10pt;margin-bottom:0pt=
;" id=3D"docs-internal-guid-3448ba09-d6b6-f3ae-2d18-ccd432498c33"><font siz=
e=3D"2">Hi everyone</font>,</h2><p>While trying to figure out what should t=
he definition of "precondition" be in C++, I collected a number of examples=
 of potential preconditions, and things that could be confused with precond=
itions, from the Standard Library. These could serve as a basis for choosin=
g the semantics of preconditions. If you can think of any other kind of exp=
ectations on function inputs that could possibly qualify for preconditions,=
 please let me know.</p><p>Regards,<br>&amp;rzej</p><p><br></p><h2 dir=3D"l=
tr" style=3D"line-height:1.15;margin-top:10pt;margin-bottom:0pt;" id=3D"doc=
s-internal-guid-3448ba09-d6b6-f3ae-2d18-ccd432498c33"><span style=3D"font-s=
ize:17px;font-family:'Trebuchet MS';color:#000000;background-color:transpar=
ent;font-weight:bold;font-style:normal;font-variant:normal;text-decoration:=
none;vertical-align:baseline;">UB for performance reasons</span></h2><p dir=
=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;"><span=
 style=3D"font-size:15px;font-family:Arial;color:#000000;background-color:t=
ransparent;font-weight:normal;font-style:normal;font-variant:normal;text-de=
coration:none;vertical-align:baseline;">21.4.5 (</span><span style=3D"font-=
size:15px;font-family:'Courier New';color:#000000;background-color:transpar=
ent;font-weight:normal;font-style:normal;font-variant:normal;text-decoratio=
n:none;vertical-align:baseline;">basic_string</span><span style=3D"font-siz=
e:15px;font-family:Arial;color:#000000;background-color:transparent;font-we=
ight:normal;font-style:normal;font-variant:normal;text-decoration:none;vert=
ical-align:baseline;"> element access), paragraphs 1 and 3 :</span></p><p d=
ir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;"><sp=
an style=3D"font-size:15px;font-family:Arial;color:#000000;background-color=
:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-=
decoration:none;vertical-align:baseline;">&nbsp;&nbsp;&nbsp; </span><span s=
tyle=3D"font-size:15px;font-family:'Courier New';color:#000000;background-c=
olor:transparent;font-weight:normal;font-style:normal;font-variant:normal;t=
ext-decoration:none;vertical-align:baseline;">reference operator[](size_typ=
e pos);</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;m=
argin-bottom:0pt;"><span style=3D"font-size:15px;font-family:Arial;color:#0=
00000;background-color:transparent;font-weight:normal;font-style:normal;fon=
t-variant:normal;text-decoration:none;vertical-align:baseline;">&nbsp;&nbsp=
;&nbsp; </span><span style=3D"font-size:15px;font-family:Arial;color:#00000=
0;background-color:transparent;font-weight:normal;font-style:italic;font-va=
riant:normal;text-decoration:none;vertical-align:baseline;">Requires:</span=
><span style=3D"font-size:15px;font-family:Arial;color:#000000;background-c=
olor:transparent;font-weight:normal;font-style:normal;font-variant:normal;t=
ext-decoration:none;vertical-align:baseline;"> </span><span style=3D"font-s=
ize:15px;font-family:'Courier New';color:#000000;background-color:transpare=
nt;font-weight:normal;font-style:normal;font-variant:normal;text-decoration=
:none;vertical-align:baseline;">pos &lt;=3D size()</span><span style=3D"fon=
t-size:15px;font-family:Arial;color:#000000;background-color:transparent;fo=
nt-weight:normal;font-style:normal;font-variant:normal;text-decoration:none=
;vertical-align:baseline;">.</span></p><p dir=3D"ltr" style=3D"line-height:=
1.15;margin-top:0pt;margin-bottom:0pt;"><span style=3D"font-size:15px;font-=
family:Arial;color:#000000;background-color:transparent;font-weight:normal;=
font-style:normal;font-variant:normal;text-decoration:none;vertical-align:b=
aseline;">&nbsp;&nbsp;&nbsp; </span><span style=3D"font-size:15px;font-fami=
ly:Arial;color:#000000;background-color:transparent;font-weight:normal;font=
-style:italic;font-variant:normal;text-decoration:none;vertical-align:basel=
ine;">Throws:</span><span style=3D"font-size:15px;font-family:Arial;color:#=
000000;background-color:transparent;font-weight:normal;font-style:normal;fo=
nt-variant:normal;text-decoration:none;vertical-align:baseline;"> Nothing.<=
/span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bo=
ttom:0pt;"><span style=3D"font-size:15px;font-family:Arial;color:#000000;ba=
ckground-color:transparent;font-weight:normal;font-style:normal;font-varian=
t:normal;text-decoration:none;vertical-align:baseline;">To
 guarantee the maximum run-time performance we require of the callers=20
that they make sure the precondition holds. Somewhat similar example:</span=
></p><br><span style=3D"font-size:15px;font-family:Arial;color:#000000;back=
ground-color:transparent;font-weight:normal;font-style:normal;font-variant:=
normal;text-decoration:none;vertical-align:baseline;"></span><p dir=3D"ltr"=
 style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;"><span style=
=3D"font-size:15px;font-family:Arial;color:#000000;background-color:transpa=
rent;font-weight:normal;font-style:normal;font-variant:normal;text-decorati=
on:none;vertical-align:baseline;">25.4.3.4 (</span><span style=3D"font-size=
:15px;font-family:'Courier New';color:#000000;background-color:transparent;=
font-weight:normal;font-style:normal;font-variant:normal;text-decoration:no=
ne;vertical-align:baseline;">binary_search</span><span style=3D"font-size:1=
5px;font-family:Arial;color:#000000;background-color:transparent;font-weigh=
t:normal;font-style:normal;font-variant:normal;text-decoration:none;vertica=
l-align:baseline;">), paragraph 1:</span></p><p dir=3D"ltr" style=3D"line-h=
eight:1.15;margin-top:0pt;margin-bottom:0pt;text-indent: 36pt;"><span style=
=3D"font-size:15px;font-family:'Courier New';color:#000000;background-color=
:transparent;font-weight:normal;font-style:normal;font-variant:normal;text-=
decoration:none;vertical-align:baseline;">template&lt;class ForwardIterator=
, class T, class Compare&gt;</span></p><p dir=3D"ltr" style=3D"line-height:=
1.15;margin-top:0pt;margin-bottom:0pt;text-indent: 36pt;"><span style=3D"fo=
nt-size:15px;font-family:'Courier New';color:#000000;background-color:trans=
parent;font-weight:normal;font-style:normal;font-variant:normal;text-decora=
tion:none;vertical-align:baseline;">bool binary_search(ForwardIterator firs=
t, ForwardIterator last,</span></p><p dir=3D"ltr" style=3D"line-height:1.15=
;margin-top:0pt;margin-bottom:0pt;text-indent: 36pt;"><span style=3D"font-s=
ize:15px;font-family:'Courier New';color:#000000;background-color:transpare=
nt;font-weight:normal;font-style:normal;font-variant:normal;text-decoration=
:none;vertical-align:baseline;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const T&a=
mp; value, Compare comp);</span></p><p dir=3D"ltr" style=3D"line-height:1.1=
5;margin-top:0pt;margin-bottom:0pt;margin-left: 36pt;"><span style=3D"font-=
size:15px;font-family:Arial;color:#000000;background-color:transparent;font=
-weight:normal;font-style:italic;font-variant:normal;text-decoration:none;v=
ertical-align:baseline;">Requires: </span><span style=3D"font-size:15px;fon=
t-family:Arial;color:#000000;background-color:transparent;font-weight:norma=
l;font-style:normal;font-variant:normal;text-decoration:none;vertical-align=
:baseline;">The elements </span><span style=3D"font-size:15px;font-family:'=
Courier New';color:#000000;background-color:transparent;font-weight:normal;=
font-style:normal;font-variant:normal;text-decoration:none;vertical-align:b=
aseline;">e</span><span style=3D"font-size:15px;font-family:Arial;color:#00=
0000;background-color:transparent;font-weight:normal;font-style:normal;font=
-variant:normal;text-decoration:none;vertical-align:baseline;"> of </span><=
span style=3D"font-size:15px;font-family:'Courier New';color:#000000;backgr=
ound-color:transparent;font-weight:normal;font-style:normal;font-variant:no=
rmal;text-decoration:none;vertical-align:baseline;">[first,last)</span><spa=
n style=3D"font-size:15px;font-family:Arial;color:#000000;background-color:=
transparent;font-weight:normal;font-style:normal;font-variant:normal;text-d=
ecoration:none;vertical-align:baseline;"> are partitioned with respect to t=
he expressions </span><span style=3D"font-size:15px;font-family:'Courier Ne=
w';color:#000000;background-color:transparent;font-weight:normal;font-style=
:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;">=
comp(e, value)</span><span style=3D"font-size:15px;font-family:Arial;color:=
#000000;background-color:transparent;font-weight:normal;font-style:normal;f=
ont-variant:normal;text-decoration:none;vertical-align:baseline;"> and </sp=
an><span style=3D"font-size:15px;font-family:'Courier New';color:#000000;ba=
ckground-color:transparent;font-weight:normal;font-style:normal;font-varian=
t:normal;text-decoration:none;vertical-align:baseline;">!comp(value, e)</sp=
an><span style=3D"font-size:15px;font-family:Arial;color:#000000;background=
-color:transparent;font-weight:normal;font-style:normal;font-variant:normal=
;text-decoration:none;vertical-align:baseline;">. Also, for all elements </=
span><span style=3D"font-size:15px;font-family:'Courier New';color:#000000;=
background-color:transparent;font-weight:normal;font-style:normal;font-vari=
ant:normal;text-decoration:none;vertical-align:baseline;">e</span><span sty=
le=3D"font-size:15px;font-family:Arial;color:#000000;background-color:trans=
parent;font-weight:normal;font-style:normal;font-variant:normal;text-decora=
tion:none;vertical-align:baseline;"> of</span><span style=3D"font-size:15px=
;font-family:'Courier New';color:#000000;background-color:transparent;font-=
weight:normal;font-style:normal;font-variant:normal;text-decoration:none;ve=
rtical-align:baseline;"> [first, last)</span><span style=3D"font-size:15px;=
font-family:Arial;color:#000000;background-color:transparent;font-weight:no=
rmal;font-style:normal;font-variant:normal;text-decoration:none;vertical-al=
ign:baseline;">, </span><span style=3D"font-size:15px;font-family:'Courier =
New';color:#000000;background-color:transparent;font-weight:normal;font-sty=
le:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;=
">comp(e, value)</span><span style=3D"font-size:15px;font-family:Arial;colo=
r:#000000;background-color:transparent;font-weight:normal;font-style:normal=
;font-variant:normal;text-decoration:none;vertical-align:baseline;"> implie=
s </span><span style=3D"font-size:15px;font-family:'Courier New';color:#000=
000;background-color:transparent;font-weight:normal;font-style:normal;font-=
variant:normal;text-decoration:none;vertical-align:baseline;">!comp(value, =
e)</span><span style=3D"font-size:15px;font-family:Arial;color:#000000;back=
ground-color:transparent;font-weight:normal;font-style:normal;font-variant:=
normal;text-decoration:none;vertical-align:baseline;">.</span></p><br><span=
 style=3D"font-size:15px;font-family:Arial;color:#000000;background-color:t=
ransparent;font-weight:normal;font-style:normal;font-variant:normal;text-de=
coration:none;vertical-align:baseline;"></span><p dir=3D"ltr" style=3D"line=
-height:1.15;margin-top:0pt;margin-bottom:0pt;"><span style=3D"font-size:15=
px;font-family:Arial;color:#000000;background-color:transparent;font-weight=
:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical=
-align:baseline;">Here, most of the requirement could be expressed with C++=
 expressions (using C++14 polymorphic lambdas):</span></p><p dir=3D"ltr" st=
yle=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;"><span style=3D"f=
ont-size:15px;font-family:Arial;color:#000000;background-color:transparent;=
font-weight:normal;font-style:normal;font-variant:normal;text-decoration:no=
ne;vertical-align:baseline;">&nbsp;&nbsp;&nbsp; </span><span style=3D"font-=
size:15px;font-family:'Courier New';color:#000000;background-color:transpar=
ent;font-weight:normal;font-style:normal;font-variant:normal;text-decoratio=
n:none;vertical-align:baseline;">is_partitioned(first, last, [&amp;value](a=
uto&amp;&amp; e){</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin=
-top:0pt;margin-bottom:0pt;margin-left: 36pt;text-indent: 36pt;"><span styl=
e=3D"font-size:15px;font-family:'Courier New';color:#000000;background-colo=
r:transparent;font-weight:normal;font-style:normal;font-variant:normal;text=
-decoration:none;vertical-align:baseline;">return comp(e, value);</span></p=
><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;=
margin-left: 36pt;"><span style=3D"font-size:15px;font-family:'Courier New'=
;color:#000000;background-color:transparent;font-weight:normal;font-style:n=
ormal;font-variant:normal;text-decoration:none;vertical-align:baseline;">})=
;</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-=
bottom:0pt;text-indent: 36pt;"><span style=3D"font-size:15px;font-family:'C=
ourier New';color:#000000;background-color:transparent;font-weight:normal;f=
ont-style:normal;font-variant:normal;text-decoration:none;vertical-align:ba=
seline;">is_partitioned(first, last, [&amp;value](auto&amp;&amp; e){</span>=
</p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0=
pt;margin-left: 36pt;text-indent: 36pt;"><span style=3D"font-size:15px;font=
-family:'Courier New';color:#000000;background-color:transparent;font-weigh=
t:normal;font-style:normal;font-variant:normal;text-decoration:none;vertica=
l-align:baseline;">return !comp(value, e);</span></p><p dir=3D"ltr" style=
=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;margin-left: 36pt;"><=
span style=3D"font-size:15px;font-family:'Courier New';color:#000000;backgr=
ound-color:transparent;font-weight:normal;font-style:normal;font-variant:no=
rmal;text-decoration:none;vertical-align:baseline;">});</span></p><p dir=3D=
"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;margin-lef=
t: 36pt;"><span style=3D"font-size:15px;font-family:'Courier New';color:#00=
0000;background-color:transparent;font-weight:normal;font-style:normal;font=
-variant:normal;text-decoration:none;vertical-align:baseline;">all_of(first=
, last, [&amp;value](auto&amp;&amp; e){</span></p><p dir=3D"ltr" style=3D"l=
ine-height:1.15;margin-top:0pt;margin-bottom:0pt;margin-left: 36pt;"><span =
style=3D"font-size:15px;font-family:'Courier New';color:#000000;background-=
color:transparent;font-weight:normal;font-style:normal;font-variant:normal;=
text-decoration:none;vertical-align:baseline;">&nbsp;&nbsp;&nbsp; return !c=
omp(e, value) || !comp(value, e); </span><span style=3D"font-size:15px;font=
-family:Arial;color:#000000;background-color:transparent;font-weight:normal=
;font-style:italic;font-variant:normal;text-decoration:none;vertical-align:=
baseline;">// antisymmetry</span></p><p dir=3D"ltr" style=3D"line-height:1.=
15;margin-top:0pt;margin-bottom:0pt;margin-left: 36pt;"><span style=3D"font=
-size:15px;font-family:'Courier New';color:#000000;background-color:transpa=
rent;font-weight:normal;font-style:normal;font-variant:normal;text-decorati=
on:none;vertical-align:baseline;">});</span></p><p dir=3D"ltr" style=3D"lin=
e-height:1.15;margin-top:0pt;margin-bottom:0pt;"><span style=3D"font-size:1=
5px;font-family:Arial;color:#000000;background-color:transparent;font-weigh=
t:normal;font-style:normal;font-variant:normal;text-decoration:none;vertica=
l-align:baseline;">However, the runtime complexity of </span><span style=3D=
"font-size:15px;font-family:'Courier New';color:#000000;background-color:tr=
ansparent;font-weight:normal;font-style:normal;font-variant:normal;text-dec=
oration:none;vertical-align:baseline;">binary_search </span><span style=3D"=
font-size:15px;font-family:Arial;color:#000000;background-color:transparent=
;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:n=
one;vertical-align:baseline;">is O(log(</span><span style=3D"font-size:15px=
;font-family:Arial;color:#000000;background-color:transparent;font-weight:n=
ormal;font-style:italic;font-variant:normal;text-decoration:none;vertical-a=
lign:baseline;">n</span><span style=3D"font-size:15px;font-family:Arial;col=
or:#000000;background-color:transparent;font-weight:normal;font-style:norma=
l;font-variant:normal;text-decoration:none;vertical-align:baseline;">)) whi=
le the complexity of the precondition is O(</span><span style=3D"font-size:=
15px;font-family:Arial;color:#000000;background-color:transparent;font-weig=
ht:normal;font-style:italic;font-variant:normal;text-decoration:none;vertic=
al-align:baseline;">n</span><span style=3D"font-size:15px;font-family:Arial=
;color:#000000;background-color:transparent;font-weight:normal;font-style:n=
ormal;font-variant:normal;text-decoration:none;vertical-align:baseline;">).=
 </span></p><br><span style=3D"font-size:15px;font-family:Arial;color:#0000=
00;background-color:transparent;font-weight:normal;font-style:normal;font-v=
ariant:normal;text-decoration:none;vertical-align:baseline;"></span><p dir=
=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;"><span=
 style=3D"font-size:15px;font-family:Arial;color:#000000;background-color:t=
ransparent;font-weight:normal;font-style:normal;font-variant:normal;text-de=
coration:none;vertical-align:baseline;">However, there is also one implied =
precondition that cannot be easily expressed: </span><span style=3D"font-si=
ze:15px;font-family:'Courier New';color:#000000;background-color:transparen=
t;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:=
none;vertical-align:baseline;">first</span><span style=3D"font-size:15px;fo=
nt-family:Arial;color:#000000;background-color:transparent;font-weight:norm=
al;font-style:normal;font-variant:normal;text-decoration:none;vertical-alig=
n:baseline;"> and </span><span style=3D"font-size:15px;font-family:'Courier=
 New';color:#000000;background-color:transparent;font-weight:normal;font-st=
yle:normal;font-variant:normal;text-decoration:none;vertical-align:baseline=
;">last </span><span style=3D"font-size:15px;font-family:Arial;color:#00000=
0;background-color:transparent;font-weight:normal;font-style:normal;font-va=
riant:normal;text-decoration:none;vertical-align:baseline;">must form a val=
id range. That is, there is no expression that can return </span><span styl=
e=3D"font-size:15px;font-family:'Courier New';color:#000000;background-colo=
r:transparent;font-weight:normal;font-style:normal;font-variant:normal;text=
-decoration:none;vertical-align:baseline;">true </span><span style=3D"font-=
size:15px;font-family:Arial;color:#000000;background-color:transparent;font=
-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;v=
ertical-align:baseline;">for all valid ranges and </span><span style=3D"fon=
t-size:15px;font-family:'Courier New';color:#000000;background-color:transp=
arent;font-weight:normal;font-style:normal;font-variant:normal;text-decorat=
ion:none;vertical-align:baseline;">false </span><span style=3D"font-size:15=
px;font-family:Arial;color:#000000;background-color:transparent;font-weight=
:normal;font-style:normal;font-variant:normal;text-decoration:none;vertical=
-align:baseline;">for all invalid ranges. This is somewhat similar to check=
ing if a non-null pointer points to valid memory.</span></p><h2 dir=3D"ltr"=
 style=3D"line-height:1.15;margin-top:10pt;margin-bottom:0pt;"><span style=
=3D"font-size:17px;font-family:'Trebuchet MS';color:#000000;background-colo=
r:transparent;font-weight:bold;font-style:normal;font-variant:normal;text-d=
ecoration:none;vertical-align:baseline;">=93Logical=94 error with guarantee=
d error report</span></h2><p dir=3D"ltr" style=3D"line-height:1.15;margin-t=
op:0pt;margin-bottom:0pt;"><span style=3D"font-size:15px;font-family:Arial;=
color:#000000;background-color:transparent;font-weight:normal;font-style:no=
rmal;font-variant:normal;text-decoration:none;vertical-align:baseline;">21.=
4.5 (</span><span style=3D"font-size:15px;font-family:'Courier New';color:#=
000000;background-color:transparent;font-weight:normal;font-style:normal;fo=
nt-variant:normal;text-decoration:none;vertical-align:baseline;">basic_stri=
ng</span><span style=3D"font-size:15px;font-family:Arial;color:#000000;back=
ground-color:transparent;font-weight:normal;font-style:normal;font-variant:=
normal;text-decoration:none;vertical-align:baseline;"> element access), par=
agraphs 5 - 6:</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-to=
p:0pt;margin-bottom:0pt;text-indent: 36pt;"><span style=3D"font-size:15px;f=
ont-family:'Courier New';color:#000000;background-color:transparent;font-we=
ight:normal;font-style:normal;font-variant:normal;text-decoration:none;vert=
ical-align:baseline;">reference at(size_type pos);</span></p><p dir=3D"ltr"=
 style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent: 36=
pt;"><span style=3D"font-size:15px;font-family:Arial;color:#000000;backgrou=
nd-color:transparent;font-weight:normal;font-style:italic;font-variant:norm=
al;text-decoration:none;vertical-align:baseline;">Requires:</span><span sty=
le=3D"font-size:15px;font-family:Arial;color:#000000;background-color:trans=
parent;font-weight:normal;font-style:normal;font-variant:normal;text-decora=
tion:none;vertical-align:baseline;"> </span><span style=3D"font-size:15px;f=
ont-family:'Courier New';color:#000000;background-color:transparent;font-we=
ight:normal;font-style:normal;font-variant:normal;text-decoration:none;vert=
ical-align:baseline;">pos &lt; size()</span></p><p dir=3D"ltr" style=3D"lin=
e-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent: 36pt;"><span st=
yle=3D"font-size:15px;font-family:Arial;color:#000000;background-color:tran=
sparent;font-weight:normal;font-style:italic;font-variant:normal;text-decor=
ation:none;vertical-align:baseline;">Throws:</span><span style=3D"font-size=
:15px;font-family:Arial;color:#000000;background-color:transparent;font-wei=
ght:normal;font-style:normal;font-variant:normal;text-decoration:none;verti=
cal-align:baseline;"> </span><span style=3D"font-size:15px;font-family:'Cou=
rier New';color:#000000;background-color:transparent;font-weight:normal;fon=
t-style:normal;font-variant:normal;text-decoration:none;vertical-align:base=
line;">out_of_range</span><span style=3D"font-size:15px;font-family:Arial;c=
olor:#000000;background-color:transparent;font-weight:normal;font-style:nor=
mal;font-variant:normal;text-decoration:none;vertical-align:baseline;"> if =
</span><span style=3D"font-size:15px;font-family:'Courier New';color:#00000=
0;background-color:transparent;font-weight:normal;font-style:normal;font-va=
riant:normal;text-decoration:none;vertical-align:baseline;">pos &gt;=3D siz=
e()</span><span style=3D"font-size:15px;font-family:Arial;color:#000000;bac=
kground-color:transparent;font-weight:normal;font-style:normal;font-variant=
:normal;text-decoration:none;vertical-align:baseline;">.</span></p><br><spa=
n style=3D"font-size:15px;font-family:Arial;color:#000000;background-color:=
transparent;font-weight:normal;font-style:normal;font-variant:normal;text-d=
ecoration:none;vertical-align:baseline;"></span><p dir=3D"ltr" style=3D"lin=
e-height:1.15;margin-top:0pt;margin-bottom:0pt;"><span style=3D"font-size:1=
5px;font-family:Arial;color:#000000;background-color:transparent;font-weigh=
t:normal;font-style:normal;font-variant:normal;text-decoration:none;vertica=
l-align:baseline;">This
 is accompanied by the controversial requirement from the standard=20
(17.6.4.11): =93Violation of the preconditions specified in a function=92s =
</span><span style=3D"font-size:15px;font-family:Arial;color:#000000;backgr=
ound-color:transparent;font-weight:normal;font-style:italic;font-variant:no=
rmal;text-decoration:none;vertical-align:baseline;">Requires:</span><span s=
tyle=3D"font-size:15px;font-family:Arial;color:#000000;background-color:tra=
nsparent;font-weight:normal;font-style:normal;font-variant:normal;text-deco=
ration:none;vertical-align:baseline;"> paragraph results in undefined behav=
ior</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margi=
n-bottom:0pt;"><span style=3D"font-size:15px;font-family:Arial;color:#00000=
0;background-color:transparent;font-weight:normal;font-style:normal;font-va=
riant:normal;text-decoration:none;vertical-align:baseline;">unless the func=
tion=92s </span><span style=3D"font-size:15px;font-family:Arial;color:#0000=
00;background-color:transparent;font-weight:normal;font-style:italic;font-v=
ariant:normal;text-decoration:none;vertical-align:baseline;">Throws:</span>=
<span style=3D"font-size:15px;font-family:Arial;color:#000000;background-co=
lor:transparent;font-weight:normal;font-style:normal;font-variant:normal;te=
xt-decoration:none;vertical-align:baseline;"> paragraph specifies throwing =
an exception when the precondition is violated.=94</span></p><p dir=3D"ltr"=
 style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;"><span style=
=3D"font-size:15px;font-family:Arial;color:#000000;background-color:transpa=
rent;font-weight:normal;font-style:normal;font-variant:normal;text-decorati=
on:none;vertical-align:baseline;">Here,
 it is very well defined what happens in case we provide the=20
out-of-range index. This makes the following program well defined:</span></=
p><br><span style=3D"font-size:15px;font-family:Arial;color:#000000;backgro=
und-color:transparent;font-weight:normal;font-style:normal;font-variant:nor=
mal;text-decoration:none;vertical-align:baseline;"></span><p dir=3D"ltr" st=
yle=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;margin-left: 36pt;=
"><span style=3D"font-size:15px;font-family:'Courier New';color:#000000;bac=
kground-color:transparent;font-weight:normal;font-style:normal;font-variant=
:normal;text-decoration:none;vertical-align:baseline;">void listChars(strin=
g const&amp; s)</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-t=
op:0pt;margin-bottom:0pt;margin-left: 36pt;"><span style=3D"font-size:15px;=
font-family:'Courier New';color:#000000;background-color:transparent;font-w=
eight:normal;font-style:normal;font-variant:normal;text-decoration:none;ver=
tical-align:baseline;">{</span></p><p dir=3D"ltr" style=3D"line-height:1.15=
;margin-top:0pt;margin-bottom:0pt;margin-left: 72pt;"><span style=3D"font-s=
ize:15px;font-family:'Courier New';color:#000000;background-color:transpare=
nt;font-weight:normal;font-style:normal;font-variant:normal;text-decoration=
:none;vertical-align:baseline;">int i =3D 0;</span></p><p dir=3D"ltr" style=
=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;margin-left: 72pt;"><=
span style=3D"font-size:15px;font-family:'Courier New';color:#000000;backgr=
ound-color:transparent;font-weight:normal;font-style:normal;font-variant:no=
rmal;text-decoration:none;vertical-align:baseline;">try {</span></p><p dir=
=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;margin-=
left: 72pt;text-indent: 36pt;"><span style=3D"font-size:15px;font-family:'C=
ourier New';color:#000000;background-color:transparent;font-weight:normal;f=
ont-style:normal;font-variant:normal;text-decoration:none;vertical-align:ba=
seline;">while(true) cout &lt;&lt; vec.at(i++);</span></p><p dir=3D"ltr" st=
yle=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;margin-left: 72pt;=
"><span style=3D"font-size:15px;font-family:'Courier New';color:#000000;bac=
kground-color:transparent;font-weight:normal;font-style:normal;font-variant=
:normal;text-decoration:none;vertical-align:baseline;">}</span></p><p dir=
=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;margin-=
left: 72pt;"><span style=3D"font-size:15px;font-family:'Courier New';color:=
#000000;background-color:transparent;font-weight:normal;font-style:normal;f=
ont-variant:normal;text-decoration:none;vertical-align:baseline;">catch(out=
_of_range const&amp;) {}</span></p><p dir=3D"ltr" style=3D"line-height:1.15=
;margin-top:0pt;margin-bottom:0pt;text-indent: 36pt;"><span style=3D"font-s=
ize:15px;font-family:'Courier New';color:#000000;background-color:transpare=
nt;font-weight:normal;font-style:normal;font-variant:normal;text-decoration=
:none;vertical-align:baseline;">}</span><span style=3D"font-size:15px;font-=
family:Arial;color:#000000;background-color:transparent;font-weight:normal;=
font-style:normal;font-variant:normal;text-decoration:none;vertical-align:b=
aseline;"></span></p><br><span style=3D"font-size:15px;font-family:Arial;co=
lor:#000000;background-color:transparent;font-weight:normal;font-style:norm=
al;font-variant:normal;text-decoration:none;vertical-align:baseline;"></spa=
n><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt=
;"><span style=3D"font-size:15px;font-family:Arial;color:#000000;background=
-color:transparent;font-weight:normal;font-style:normal;font-variant:normal=
;text-decoration:none;vertical-align:baseline;">The
 question is, why call out-of-range a =93precondition=94 if we accept it as=
=20
well-defined input? What is the definition of a precondition? What is=20
the purpose of specifying one? Is it a license to the compiler for=20
rejecting any code where it can prove that a precondition is violated?=20
So should smart compilers be allowed to reject functions like </span><span =
style=3D"font-size:15px;font-family:'Courier New';color:#000000;background-=
color:transparent;font-weight:normal;font-style:normal;font-variant:normal;=
text-decoration:none;vertical-align:baseline;">listChars</span><span style=
=3D"font-size:15px;font-family:Arial;color:#000000;background-color:transpa=
rent;font-weight:normal;font-style:normal;font-variant:normal;text-decorati=
on:none;vertical-align:baseline;"> above? Or is precondition only a hint on=
 usage for other developers?</span></p><h2 dir=3D"ltr" style=3D"line-height=
:1.15;margin-top:10pt;margin-bottom:0pt;"><span style=3D"font-size:17px;fon=
t-family:'Trebuchet MS';color:#000000;background-color:transparent;font-wei=
ght:bold;font-style:normal;font-variant:normal;text-decoration:none;vertica=
l-align:baseline;">Only an irregular input</span></h2><p dir=3D"ltr" style=
=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;"><span style=3D"font=
-size:15px;font-family:Arial;color:#000000;background-color:transparent;fon=
t-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;=
vertical-align:baseline;">20.8.11.2.4 (</span><span style=3D"font-size:15px=
;font-family:'Courier New';color:#000000;background-color:transparent;font-=
weight:normal;font-style:normal;font-variant:normal;text-decoration:none;ve=
rtical-align:baseline;">function</span><span style=3D"font-size:15px;font-f=
amily:Arial;color:#000000;background-color:transparent;font-weight:normal;f=
ont-style:normal;font-variant:normal;text-decoration:none;vertical-align:ba=
seline;"> invocation), paragraphs 1 and 3:</span></p><p dir=3D"ltr" style=
=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;"><span style=3D"font=
-size:15px;font-family:Arial;color:#000000;background-color:transparent;fon=
t-weight:normal;font-style:normal;font-variant:normal;text-decoration:none;=
vertical-align:baseline;">&nbsp;&nbsp;&nbsp; </span><span style=3D"font-siz=
e:15px;font-family:'Courier New';color:#000000;background-color:transparent=
;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:n=
one;vertical-align:baseline;">R operator()(ArgTypes... args) const;</span><=
/p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0p=
t;margin-left: 36pt;"><span style=3D"font-size:15px;font-family:Arial;color=
:#000000;background-color:transparent;font-weight:normal;font-style:italic;=
font-variant:normal;text-decoration:none;vertical-align:baseline;">Effects:=
</span><span style=3D"font-size:15px;font-family:Arial;color:#000000;backgr=
ound-color:transparent;font-weight:normal;font-style:normal;font-variant:no=
rmal;text-decoration:none;vertical-align:baseline;"> </span><span style=3D"=
font-size:15px;font-family:'Courier New';color:#000000;background-color:tra=
nsparent;font-weight:normal;font-style:normal;font-variant:normal;text-deco=
ration:none;vertical-align:baseline;">INVOKE(f, std::forward&lt;ArgTypes&gt=
;(args)..., R)</span><span style=3D"font-size:15px;font-family:Arial;color:=
#000000;background-color:transparent;font-weight:normal;font-style:normal;f=
ont-variant:normal;text-decoration:none;vertical-align:baseline;">, where <=
/span><span style=3D"font-size:15px;font-family:'Courier New';color:#000000=
;background-color:transparent;font-weight:normal;font-style:normal;font-var=
iant:normal;text-decoration:none;vertical-align:baseline;">f</span><span st=
yle=3D"font-size:15px;font-family:Arial;color:#000000;background-color:tran=
sparent;font-weight:normal;font-style:normal;font-variant:normal;text-decor=
ation:none;vertical-align:baseline;"> is the target object of </span><span =
style=3D"font-size:15px;font-family:'Courier New';color:#000000;background-=
color:transparent;font-weight:normal;font-style:normal;font-variant:normal;=
text-decoration:none;vertical-align:baseline;">*this</span><span style=3D"f=
ont-size:15px;font-family:Arial;color:#000000;background-color:transparent;=
font-weight:normal;font-style:normal;font-variant:normal;text-decoration:no=
ne;vertical-align:baseline;">.</span></p><p dir=3D"ltr" style=3D"line-heigh=
t:1.15;margin-top:0pt;margin-bottom:0pt;margin-left: 36pt;"><span style=3D"=
font-size:15px;font-family:Arial;color:#000000;background-color:transparent=
;font-weight:normal;font-style:italic;font-variant:normal;text-decoration:n=
one;vertical-align:baseline;">Throws:</span><span style=3D"font-size:15px;f=
ont-family:Arial;color:#000000;background-color:transparent;font-weight:nor=
mal;font-style:normal;font-variant:normal;text-decoration:none;vertical-ali=
gn:baseline;"> </span><span style=3D"font-size:15px;font-family:'Courier Ne=
w';color:#000000;background-color:transparent;font-weight:normal;font-style=
:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;">=
bad_function_call</span><span style=3D"font-size:15px;font-family:Arial;col=
or:#000000;background-color:transparent;font-weight:normal;font-style:norma=
l;font-variant:normal;text-decoration:none;vertical-align:baseline;"> if </=
span><span style=3D"font-size:15px;font-family:'Courier New';color:#000000;=
background-color:transparent;font-weight:normal;font-style:normal;font-vari=
ant:normal;text-decoration:none;vertical-align:baseline;">!*this</span><spa=
n style=3D"font-size:15px;font-family:Arial;color:#000000;background-color:=
transparent;font-weight:normal;font-style:normal;font-variant:normal;text-d=
ecoration:none;vertical-align:baseline;">; otherwise, any exception thrown =
by the wrapped callable object.</span></p><br><span style=3D"font-size:15px=
;font-family:Arial;color:#000000;background-color:transparent;font-weight:n=
ormal;font-style:normal;font-variant:normal;text-decoration:none;vertical-a=
lign:baseline;"></span><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:=
0pt;margin-bottom:0pt;"><span style=3D"font-size:15px;font-family:Arial;col=
or:#000000;background-color:transparent;font-weight:normal;font-style:norma=
l;font-variant:normal;text-decoration:none;vertical-align:baseline;">23.2.3=
 (Sequence containers), paragraph 17:</span></p><p dir=3D"ltr" style=3D"lin=
e-height:1.15;margin-top:0pt;margin-bottom:0pt;"><span style=3D"font-size:1=
5px;font-family:Arial;color:#000000;background-color:transparent;font-weigh=
t:normal;font-style:normal;font-variant:normal;text-decoration:none;vertica=
l-align:baseline;">=93The member function </span><span style=3D"font-size:1=
5px;font-family:'Courier New';color:#000000;background-color:transparent;fo=
nt-weight:normal;font-style:normal;font-variant:normal;text-decoration:none=
;vertical-align:baseline;">at()</span><span style=3D"font-size:15px;font-fa=
mily:Arial;color:#000000;background-color:transparent;font-weight:normal;fo=
nt-style:normal;font-variant:normal;text-decoration:none;vertical-align:bas=
eline;"> provides bounds-checked access to container elements. </span><span=
 style=3D"font-size:15px;font-family:'Courier New';color:#000000;background=
-color:transparent;font-weight:normal;font-style:normal;font-variant:normal=
;text-decoration:none;vertical-align:baseline;">at() </span><span style=3D"=
font-size:15px;font-family:Arial;color:#000000;background-color:transparent=
;font-weight:normal;font-style:normal;font-variant:normal;text-decoration:n=
one;vertical-align:baseline;">throws </span><span style=3D"font-size:15px;f=
ont-family:'Courier New';color:#000000;background-color:transparent;font-we=
ight:normal;font-style:normal;font-variant:normal;text-decoration:none;vert=
ical-align:baseline;">out_of_range</span><span style=3D"font-size:15px;font=
-family:Arial;color:#000000;background-color:transparent;font-weight:normal=
;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:=
baseline;"> if </span><span style=3D"font-size:15px;font-family:'Courier Ne=
w';color:#000000;background-color:transparent;font-weight:normal;font-style=
:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;">=
n &gt;=3D a.size()</span><span style=3D"font-size:15px;font-family:Arial;co=
lor:#000000;background-color:transparent;font-weight:normal;font-style:norm=
al;font-variant:normal;text-decoration:none;vertical-align:baseline;">.=94<=
/span></p><br><span style=3D"font-size:15px;font-family:Arial;color:#000000=
;background-color:transparent;font-weight:normal;font-style:normal;font-var=
iant:normal;text-decoration:none;vertical-align:baseline;"></span><p dir=3D=
"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;"><span st=
yle=3D"font-size:15px;font-family:Arial;color:#000000;background-color:tran=
sparent;font-weight:normal;font-style:normal;font-variant:normal;text-decor=
ation:none;vertical-align:baseline;">In
 either case no precondition is specified, although we can intuitively=20
see that such inputs are =93fishy=94. Thus the following code is perfectly=
=20
valid:</span></p><br><span style=3D"font-size:15px;font-family:Arial;color:=
#000000;background-color:transparent;font-weight:normal;font-style:normal;f=
ont-variant:normal;text-decoration:none;vertical-align:baseline;"></span><p=
 dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;mar=
gin-left: 36pt;"><span style=3D"font-size:15px;font-family:'Courier New';co=
lor:#000000;background-color:transparent;font-weight:normal;font-style:norm=
al;font-variant:normal;text-decoration:none;vertical-align:baseline;">int p=
rocess(function&lt;int(int)&gt; f, int i)</span></p><p dir=3D"ltr" style=3D=
"line-height:1.15;margin-top:0pt;margin-bottom:0pt;margin-left: 36pt;"><spa=
n style=3D"font-size:15px;font-family:'Courier New';color:#000000;backgroun=
d-color:transparent;font-weight:normal;font-style:normal;font-variant:norma=
l;text-decoration:none;vertical-align:baseline;">{</span></p><p dir=3D"ltr"=
 style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;margin-left: 72=
pt;"><span style=3D"font-size:15px;font-family:'Courier New';color:#000000;=
background-color:transparent;font-weight:normal;font-style:normal;font-vari=
ant:normal;text-decoration:none;vertical-align:baseline;">try {</span></p><=
p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;ma=
rgin-left: 72pt;"><span style=3D"font-size:15px;font-family:'Courier New';c=
olor:#000000;background-color:transparent;font-weight:normal;font-style:nor=
mal;font-variant:normal;text-decoration:none;vertical-align:baseline;"> &nb=
sp;return f(i);</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-t=
op:0pt;margin-bottom:0pt;margin-left: 72pt;"><span style=3D"font-size:15px;=
font-family:'Courier New';color:#000000;background-color:transparent;font-w=
eight:normal;font-style:normal;font-variant:normal;text-decoration:none;ver=
tical-align:baseline;">}</span></p><p dir=3D"ltr" style=3D"line-height:1.15=
;margin-top:0pt;margin-bottom:0pt;margin-left: 72pt;"><span style=3D"font-s=
ize:15px;font-family:'Courier New';color:#000000;background-color:transpare=
nt;font-weight:normal;font-style:normal;font-variant:normal;text-decoration=
:none;vertical-align:baseline;">catch(bad_function_call const&amp;) {</span=
></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:=
0pt;margin-left: 72pt;"><span style=3D"font-size:15px;font-family:'Courier =
New';color:#000000;background-color:transparent;font-weight:normal;font-sty=
le:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;=
">&nbsp;&nbsp;&nbsp; return 0;</span></p><p dir=3D"ltr" style=3D"line-heigh=
t:1.15;margin-top:0pt;margin-bottom:0pt;margin-left: 72pt;"><span style=3D"=
font-size:15px;font-family:'Courier New';color:#000000;background-color:tra=
nsparent;font-weight:normal;font-style:normal;font-variant:normal;text-deco=
ration:none;vertical-align:baseline;">}</span></p><div style=3D"margin-left=
: 40px;"><span style=3D"font-size:15px;font-family:'Courier New';color:#000=
000;background-color:transparent;font-weight:normal;font-style:normal;font-=
variant:normal;text-decoration:none;vertical-align:baseline;">}</span></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/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_49_30658112.1369402629855--

.
