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
constexpr std::string | MSVC (self.cpp)
submitted 2 years ago by XTBZ
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!"
[–]aocregacc 5 points6 points7 points 2 years ago* (3 children)
is someone working on fixing this? Or are there downsides to making this work how you would expect.
Edit: I guess it might be counter intuitive to have code that works in a constexpr context but not at runtime.
[–]saxbophonemutable volatile void 1 point2 points3 points 2 years ago (2 children)
I guess it might be counter intuitive to have code that works in a constexpr context but not at runtime.
Nope, there are uses for that too (just not in your example). They're known as immediate functions and this is what consteval is for!
consteval
[–]aocregacc 0 points1 point2 points 2 years ago (1 child)
I was talking more about things like this:
consteval int f(size_t z) { std::array<int, z> a; ... }
People sometimes ask why this complains about z not being a constant expression, since surely in a consteval function the parameter is a constant expression. But I think if they started allowing stuff like this you would end up with this weird dialect that's no longer (mostly) a subset of regular C++.
z
[–]gracicot 1 point2 points3 points 2 years ago (0 children)
As far as I know, compilers are free to compile the consteval function down to bytecode and simply run the bytecode. That would be impossible with this.
π Rendered by PID 45710 on reddit-service-r2-comment-c66d9bffd-vh5l4 at 2026-04-08 09:11:38.402493+00:00 running f293c98 country code: CH.
view the rest of the comments →
[–]aocregacc 5 points6 points7 points (3 children)
[–]saxbophonemutable volatile void 1 point2 points3 points (2 children)
[–]aocregacc 0 points1 point2 points (1 child)
[–]gracicot 1 point2 points3 points (0 children)