C++ Logo


Advanced search

Re: [SG10] P0304: constexpr addressof

From: Richard Smith <richard_at_[hidden]>
Date: Sun, 13 Mar 2016 18:16:05 -0700
On Fri, Mar 11, 2016 at 11:30 AM, Daniel Krügler
<daniel.kruegler_at_[hidden]> wrote:
> 2016-03-11 20:27 GMT+01:00 Agustín Bergé <agustinberge_at_[hidden]>:
>> On 3/11/2016 4:14 PM, Nelson, Clark wrote:
>>> Agustin raised the question of whether there should be a macro to
>>> indicate the presence of the fix for LWG2296. I made a couple of
>>> replies suggesting that, to me, the answer is not obviously "yes".
>>> So far, no one (not even Agustin) has made any further comment.
>> I said that if there's no macro I'd prefer to leave the code broken.
>> That should have implied my motivation is weak. I think a macro fits the
>> bill, but if lacks in popularity I'm not going to push for it.
> I tentatively agree, I see no need for a feature macro here.

I can imagine a macro being useful:

struct optional {
  bool b;
  T t;
  constexpr T *get() {
    return b ?
#if __cpp_constexpr_addressof
      : nullptr;

The idea here is that it's more important that get() is constexpr than
that it works if there's an overloaded operator&, so addressof is only
used if it would actually work in a constant expression. Achieving
this result with SFINAE seems difficult.

Received on 2016-03-14 02:16:07