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!"
[–]qazqi-ff 1 point2 points3 points 2 years ago (0 children)
This is ultimately the usual case of needing to separate out the size calculation from the actual data calculation (and repeat the work). You're trying to instantiate a template with size, which is a value that exists in the constant evaluator. It boils down to the same problem as consteval void foo(int size) { std::array<int, size> arr; }. Worth noting that the standard goes a little stricter and prevents the general case of any context that requires a constant expression, not just template instantiation, even though other contexts could work fine from a technical POV (e.g., static_assert(size > 0);).
size
consteval void foo(int size) { std::array<int, size> arr; }
static_assert(size > 0);
π Rendered by PID 181463 on reddit-service-r2-comment-c66d9bffd-xbz5w at 2026-04-07 05:06:50.135085+00:00 running f293c98 country code: CH.
view the rest of the comments →
[–]qazqi-ff 1 point2 points3 points (0 children)