Timeline for constexpr overloading
Current License: CC BY-SA 3.0
22 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Apr 8, 2024 at 20:32 | answer | added | Kumputer | timeline score: -1 | |
| May 31, 2022 at 15:59 | answer | added | wermos | timeline score: 12 | |
| May 31, 2021 at 15:07 | comment | added | Amir Kirsh |
C++20 added std::is_constant_evaluated() see an answer to: Is is_constexpr possible in C++11?
|
|
| Jun 14, 2020 at 15:01 | comment | added | David Stone | @Adam: No. I am working on a paper targeting C++23: github.com/davidstone/isocpp/blob/master/… | |
| Mar 17, 2020 at 0:57 | answer | added | Amir Kirsh | timeline score: 1 | |
| Aug 23, 2018 at 12:45 | answer | added | NN_ | timeline score: 1 | |
| May 23, 2017 at 11:46 | history | edited | URL Rewriter Bot |
replaced http://stackoverflow.com/ with https://stackoverflow.com/
|
|
| Oct 7, 2016 at 18:12 | comment | added | user6846474 | Here is a partial solution to the problem: stackoverflow.com/a/39922472/6846474 | |
| Jan 31, 2016 at 4:48 | answer | added | Öö Tiib | timeline score: 10 | |
| Feb 27, 2014 at 8:27 | answer | added | Lockal | timeline score: 8 | |
| Jul 22, 2013 at 22:50 | comment | added | pyrachi | I too would like this. Another example where this would be helpful is bit/population count of a bit field. Many processors include special instructions for this, so if the constexpr function is called with non-constexpr argument I'd like to use the processor instruction. But processor instructions aren't available at compile-time so I need to use another alogrithm at compile-time. | |
| May 26, 2013 at 0:43 | comment | added | David Stone |
@Dukales: yes, I understand, which is why I said "I would like", rather than "I do like". A lot of code would be made much simpler (and code like this possible) if we had static if or whatever you want to call it. Of course, even if we had static if, I couldn't use static_assert because even though I checked that condition is a constexpr, static_assert doesn't know that I did that and it still wouldn't compile.
|
|
| May 22, 2013 at 8:07 | comment | added | Tomilov Anatoliy |
if (is_constexpr (value)) static_assert (condition); else assert (condition); Dead code elimination does not work in such way.
|
|
| Apr 3, 2012 at 4:15 | comment | added | David Stone |
Another related issue that I've recently considered is this: it would be nice to combine assert with static_assert. In other words, if the compiler can determine that an assertion would fail (due to, for example, inlining), I would like for it to just let me know at compile-time rather than waiting until I encounter it at run-time. However, if it cannot determine it at compile time, I'd want just a regular assert. It seems like the easiest way to implement this would be something like if (is_constexpr (value)) static_assert (condition); else assert (condition);
|
|
| Apr 1, 2012 at 8:23 | answer | added | A Fog | timeline score: 44 | |
| Mar 2, 2012 at 4:24 | vote | accept | David Stone | ||
| Jun 14, 2020 at 15:01 | |||||
| Jan 21, 2012 at 5:21 | history | edited | David Stone | CC BY-SA 3.0 |
Explained why this would be useful
|
| Jan 20, 2012 at 8:37 | answer | added | Matthieu M. | timeline score: 3 | |
| Jan 20, 2012 at 6:21 | comment | added | Jesse Good |
A quote from this paper seems relevant to your question. We don’t propose to make constexpr applicable to function arguments because it would be meaningless for non-inline functions (the argument would be a constant, but the function wouldn’t know which) and because it would lead to complications of the overloading rules (can I overload on constexpr-ness? — no).
|
|
| Jan 20, 2012 at 4:27 | answer | added | Nicol Bolas | timeline score: 1 | |
| Jan 20, 2012 at 4:12 | answer | added | Ben Voigt | timeline score: 7 | |
| Jan 20, 2012 at 3:54 | history | asked | David Stone | CC BY-SA 3.0 |