Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #689

Throwing in a constexpr function in C++14

X-Received by 10.236.94.39 with SMTP id m27mr1356912yhf.54.1382076602315; Thu, 17 Oct 2013 23:10:02 -0700 (PDT)
MIME-Version 1.0
Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!i2no18512860qav.0!news-out.google.com!9ni53417qaf.0!nntp.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date Fri, 18 Oct 2013 01:10:01 -0500
Return-Path <cppmods@mcgurn.dreamhost.com>
Sender std-cpp-request@vandevoorde.com
Approved james.dennett@gmail.com
Message-ID <c2d54cdf-48ca-41f1-9652-ab00f4c8ea04@googlegroups.com> (permalink)
Newsgroups comp.std.c++
From s.scott.schurr@googlemail.com
Subject Throwing in a constexpr function in C++14
Organization unknown
X-Original-Date Thu, 17 Oct 2013 21:32:01 -0700 (PDT)
X-Submission-Address std-cpp-submit@vandevoorde.com
To undisclosed-recipients:;
Date Fri, 18 Oct 2013 01:07:28 CST
Lines 60
X-Usenet-Provider http://www.giganews.com
X-Trace sv3-IWdBGQPrhkbA42oxmmjn3XwGNeQkbPcqROSzYNI3s9p1GIDUtSZa+lOtHtlO4ORNdjq/tqg02FiT1LT!zpDYR3xvn5pc5pvIj8+nungDDDBksaFTaE9+wxRS2mhm9rYfsNSPk4vRH04gWVgwUQQ7WPgP3auw!I4Ue1pG/5wo=
X-Complaints-To abuse@giganews.com
X-DMCA-Notifications http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 3581
Content-Type text/plain; charset=ISO-8859-1
Xref csiph.com comp.std.c++:689

Show key headers only | View raw


Hi C++ language lawyers,

I've hunted through the C++11 and pre-C++14 standards looking for
where they say that it is okay to put a throw in a constexpr function
or constructor as long as the throw is in an unevaluated part of the
code.

I believe that I've found the sentence in the C++11 FDIS (N3242)
that allows the constexpr throw pattern.  In Section 5.19 (Constant
Expressions) paragraph 2 it says:

  A conditional-expression is a constant expression unless it involves
  one of the following as a potentially evaluated subexpression (3.2),
  but subexpressions of logical AND (5.14), logical OR (5.15), and
  conditional (5.16) operations that are not evaluated are not
  considered...

The C++11 FDIS further reinforces the idiom with an example in Section
7.1.5 (The constexpr Specifier) paragraph 5...

  constexpr int f(bool b)
    { return b ? throw 0 : 0; } // OK

Now I'm looking for similar text in N3691 which is, I believe, a
recent preliminary version of the C++14 standard.

I know that rules for constexpr are being expanded in C++14.  But
I'm expecting that the pattern of putting an unevaluated throw in
a constexpr function as a way of error handling will still be
supported in C++14.  I see that the throwing example in Section
7.1.5 (The constexpr Specifier) paragraph 5 is still present in
N3691.

But I haven't yet located any text in N3691 comparable to the text I
found in Section 5.19 (Constant Expressions) paragraph 2 of the C++11
FDIS.

The most likely case is that the necessary C++14 text is there but
I missed it.  But possibly the text is missing intentionally.
Perhaps the constexpr throw pattern is one of those things that one
must infer from what the standard doesn't say.  Least likely, but
within the realm of possibility, is that the text is unintentionally
missing and needs to be added.

Are there any suggestions for how I should read the preliminary
C++14 standard on this subject?  References to paragraphs are
especially appreciated.

Thanks for your guidance.

SSchurr


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]

Back to comp.std.c++ | Previous | NextNext in thread | Find similar


Thread

Throwing in a constexpr function in C++14 s.scott.schurr@googlemail.com - 2013-10-18 01:07 -0600
  Re: Throwing in a constexpr function in C++14 Daniel Krügler <daniel.kruegler@googlemail.com> - 2013-10-19 11:04 -0700

csiph-web