constexpr-function Questions
2
Solved
The wording of the question title is probably incorrect and I'll fix it happily from your suggestions.
My question can be illustrated by this snippet:
#include <array>
template <typename ...
Harness asked 29/2 at 16:14
1
Solved
The keyword constexpr enforced pretty tight restrictions on functions on its introduction into the C++11 standard. These restrictions were loosened with C++14 and C++20 (most noteworthy):
C++14 al...
Greatnephew asked 23/1, 2023 at 15:37
15
Solved
It seems to me that having a "function that always returns 5" is breaking or diluting the meaning of "calling a function". There must be a reason, or a need for this capability ...
Anthurium asked 20/1, 2011 at 14:7
3
Solved
Is there a way to write a constexpr function that returns how deep a std::vector is nested?
Example:
get_vector_nested_layer_count<std::vector<std::vector<int>>>() // 2
get_...
Dowry asked 21/6, 2022 at 12:51
1
Solved
Recently I was surprised that the following code compiles in clang, gcc and msvc too (at least with their current versions).
struct A {
static const int value = 42;
};
constexpr int f(A a) { retu...
Abduct asked 22/3, 2022 at 20:46
2
Solved
I'm having some trouble with constexpr. The book C++ Primer shows a line of code:
constexpr int sz = size(); // only size() is a constexpr function
// this code is right
However the book doesn't...
Sleepwalk asked 3/4, 2015 at 15:1
3
Solved
Consider the following code:
static constexpr int make_const(const int i){
return i;
}
void t1(const int i)
{
constexpr int ii = make_const(i); // error occurs here (i is not a constant express...
Backrest asked 9/5, 2014 at 16:9
1
© 2022 - 2024 — McMap. All rights reserved.