Skip to main content
0 votes
1 answer
101 views

I use std::format in my logging, and it largely works great. However, std::format ignores extra arguments which I do not like. E.g., std::format("x = {}", x, y) compiles, so I want a ...
bers's user avatar
  • 6,309
10 votes
1 answer
244 views

I try to apply std::not_fn wrapper to an immediate consteval function. But even the simplest C++20 example #include <functional> consteval bool f() { return false; } // ok in GCC and Clang, ...
Fedor's user avatar
  • 24.7k
-6 votes
1 answer
93 views

Let's say I have the following function in a static library libutil (with the definition in one of the library's translation units, so it can't be inlined while compiling the caller's translation unit)...
Torph's user avatar
  • 36
2 votes
1 answer
173 views

I want to write a function that can obtain caller's function name, or at least its length, at compile time. I think obtaining std::source_location::current() is close to what I want and currently I'm ...
GKxx's user avatar
  • 638
2 votes
2 answers
185 views

My api would require calling runtime(constFoo(str)) to get the final result, I wanted to shorten this because the real function names are kind of verbose. To do this I need to somehow wrap the ...
 sentientbottleofwine's user avatar
5 votes
2 answers
138 views

I have been looking at how different specifiers affect linkage but need some help understanding how consteval affects linkage. The working draft of the standard says consteval implies inline (source): ...
Curtis sitruc's user avatar
6 votes
2 answers
132 views

I am trying to use the return value from a consteval function UniqueSize() inside another consteval function UniqueArra to declare an array, but this results in a compiler error saying that UniqueSize(...
aep's user avatar
  • 1,737
4 votes
1 answer
206 views

The problem Using static_assert to generate compile-time error is not always easy because it requires a constant expression as first argument. I found, on StackOverflow, several example where throw ...
Oersted's user avatar
  • 3,830
0 votes
1 answer
128 views

Out of curiosity, and with hope of learning useful compile-time techniques, I'm trying to understand how std::format performs compile-time checking of its arguments. I started from the implementation ...
Oersted's user avatar
  • 3,830
0 votes
1 answer
119 views

I'm working on a project that must limit itself to the C++11 standard. There's one particular class I'm creating (some details below) whose most important method can, I think, often be evaluated at ...
Dimitrije Kostic's user avatar
0 votes
0 answers
54 views

If i have a constexpr function with a constexpr local variable its value must be known at compile time constexpr int addSquare(int x) { constexpr int multiplier = 2; return x * x + multiplier;...
Blair Davidson's user avatar
13 votes
0 answers
224 views

// gcc: ok // clang: compile error struct arg { consteval arg(const int i) // consteval : i_(i) { chk<int>(i); // error!! } template <typename T> ...
celeta's user avatar
  • 131
4 votes
0 answers
117 views

I have a function like: consteval int func(int n) { ... } I would like to throw a deprecation warning if passed certain argument values, e.g. if the argument is less than 5: constexpr int a = ...
Fuz's user avatar
  • 325
1 vote
1 answer
155 views

I'm trying to implement a consteval lambda to compute the nth Fibonacci number. I want to create a result cache in the lambda which I can use if the result is already cached. Here's what I have up ...
Setu's user avatar
  • 1,086
3 votes
1 answer
183 views

I’m trying to learn C++23 and thought a good exercise would be writing a sprintf()-like function that —- provided the given format string is a string literal —- does a compile-time check to ensure the ...
Crutch's user avatar
  • 33

15 30 50 per page
1
2 3 4 5
9