<div class="gmail_quote">On Sun, Apr 1, 2012 at 11:23 AM, Howard Hinnant <span dir="ltr"><<a href="mailto:hhinnant@apple.com">hhinnant@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Apr 1, 2012, at 3:33 AM, Jonathan Sauer wrote:<br>
<br>
> Hello,<br>
><br>
> the attached patch constexpr-ifies <limits> as specified in FDIS as well as removes the<br>
> workarounds in libc++'s random number generators due to missing constexpr (the workarounds<br>
> don't work when using a non-standard PRNG). The corresponding tests are modified as well.<br>
><br>
> Please review and, if ok, commit.<br>
><br>
><br>
> With many thanks in advance,<br>
> Jonathan<br>
<br>
</div>Thanks Jonathan.  I've been meaning to take care of this.  The current libc++ is a mess with respect to constexpr.<br>
<br>
One of the things I want to do is to allow libc++ to emulate correct behavior even when it is compiled in C++03 mode.  And I don't believe this patch will do this.<br>
<br>
Another thing that is wrong is that I have an ugly hack in <__config> that needs to be fixed:<br>
<br>
#ifdef _LIBCPP_HAS_NO_CONSTEXPR<br>
#define constexpr const<br>
#endif<br>
<br>
This is just wrong, but taking it out is going to take a little more work.  I haven't nailed down exactly how we want to support both C++03 and C++11 mode, but I'm imagining something similar to the way we're handling noexcept:<br>

<br>
#ifndef _LIBCPP_HAS_NO_CONSTEXPR<br>
#define _CONSTEXPR_1 constexpr<br>
#define _CONSTEXPR_0 constexpr<br>
#else<br>
#define _CONSTEXPR_1 const<br>
#define _CONSTEXPR_0<br>
#endif<br>
<br>
(better macro names would be great!)<br>
<br>
Like I said, this has been on my to-do list, and I guess now is the time.</blockquote><div><br></div><div>How about just:</div><div><br></div><div>#ifndef _LIBCPP_HAS_NO_CONSTEXPR</div><div>#define _LIBCPP_CONSTEXPR constexpr</div>
<div>#else</div><div>#define _LIBCPP_CONSTEXPR</div><div>#endif</div><div><br></div><div>Then use</div><div><br></div><div>_LIBCPP_CONSTEXPR const int n = 5;</div><div><br></div><div>for variables, and</div><div><br></div>
<div>struct S {</div><div>  _LIBCPP_CONSTEXPR int f() const;</div><div>};</div><div><br></div><div>for functions.</div></div>