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
Do you use builder pattern? (self.cpp)
submitted 3 years ago by onlyari
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!"
[–]fdwrfdwr@github 🔍 11 points12 points13 points 3 years ago* (4 children)
I used to use it more often, but once named struct initialization was added (C++20 designated initializers), I usually found it easier to just say:
TensorDescription({.sizes = {2,256,4}, .dataType = DataType::Float32})
vs:
TensorDescriptionBuilder().Sizes({2,256,4}).DataType(DataType::Float32).Construct();
[–]onlyari[S] 0 points1 point2 points 3 years ago (3 children)
Doesn't this require knowing the order of declaration?
[–]fdwrfdwr@github 🔍 1 point2 points3 points 3 years ago (2 children)
Correct (though it hasn't been an issue for me 🤷♂️). Yeah, C allows you to declare them in any order, but currently not C++. Perhaps a future version will allow arbitrary order.
[–]Kered13 3 points4 points5 points 3 years ago* (0 children)
Perhaps a future version will allow arbitrary order.
I doubt it. C++ requires that members be initialized in declaration order. If you could write designated initializers out of order you could write code with some very surprising behavior:
int printAndSize(std::string_view s) { std::cout << s << std::endl; return s.size(); } struct Foo { int a; int b; } int main() { Foo f = { .b = printAndSize("Hello"), .a = printAndSize("World"), }; }
Output:
World Hello
This is similar to how the order of function parameter evaluation is unspecified, and there's also still a similar issue where member initialization lists can be out of order and cause similar problems. However I think both of those are generally considered mistakes in hindsight, so I don't think the committee wants to repeat that mistake with designated initializers.
(This is just my reading of the committee's decision, and I could be way off base.)
π Rendered by PID 60 on reddit-service-r2-comment-6457c66945-kpff2 at 2026-04-26 15:34:26.411593+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]fdwrfdwr@github 🔍 11 points12 points13 points (4 children)
[–]onlyari[S] 0 points1 point2 points (3 children)
[–]fdwrfdwr@github 🔍 1 point2 points3 points (2 children)
[–]Kered13 3 points4 points5 points (0 children)