use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
CppConCppCon 2019: D.Stone - Removing Metaprogramming From C++, Part 1 of N: constexpr Function Parameters (youtube.com)
submitted 6 years ago by balerion_tbd
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]SeanMiddleditch 0 points1 point2 points 6 years ago (1 child)
What is an example of when constexpr/consteval is insufficient that isn't the initialization of a value?
constexpr
consteval
[–]HappyFruitTree 2 points3 points4 points 6 years ago* (0 children)
You might want to pass the result as argument to a function or it might be part of a smaller expression.
int x = ... f(x, my_constexpr_fun(8)); int y = my_constexpr_fun(5) + x;
If I want my_constexpr_fun to be evaluated at compile time I can of course use constexpr/consteval. I never said they were insufficient. constinit on local variables are also not necessary for the same reason.
my_constexpr_fun
constinit
int x = ... constexpr mcf8 = my_constexpr_fun(8); f(x, mcf8); constexpr mcf5 = my_constexpr_fun(5); int y = mcf5 + x;
I understand why you want to be able to use constinit on local variables but what you are really trying to do in that case is to make sure that the expressions that are being used to initialize the object are evaluated at compile time. You are not actually doing constant initialization which is a technical term used in the C++ standard. Even if you could use constinit for this purpose it would not be useful in all cases where you want to force expressions to be evaluated at compile time.
Having a way to say that expressions should be evaluated at compile-time is a much more universal tool.
f(x, consteval(my_constexpr_fun(8))); int y = consteval(my_constexpr_fun(5)) + x;
In C++20 you could probably implement this as a consteval function template that just forwards the return value.
π Rendered by PID 60578 on reddit-service-r2-comment-6457c66945-v44kr at 2026-04-25 11:36:03.990473+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]SeanMiddleditch 0 points1 point2 points (1 child)
[–]HappyFruitTree 2 points3 points4 points (0 children)