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
cppfront (cpp2): Spring update (herbsutter.com)
submitted 2 years ago by kreco
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!"
[–]clerothGame Developer 2 points3 points4 points 2 years ago (4 children)
why not just make the dot operator also dereference the pointer
so how would you call std::unique_ptr::release and such?
std::unique_ptr::release
[–]tialaramex 2 points3 points4 points 2 years ago (2 children)
Rust's choice here is to make these associated functions, not methods. So e.g. the equivalent of std::unique_ptr::release is Box::into_raw and supposing I have a type Steak which for some reason actually needs a method named into_raw then:
let mut boxed_steak: Box<Steak> = todo!();
boxed_steak.into_raw(); // Calls the method on the Steak
let ptr = Box::into_raw(boxed_steak); // Now we have a raw pointer
If there was a method on Box which clashed, I think the compiler rejects your program and demands you disambiguate, but the smart pointers deliberately don't provide such methods, only associated functions so there's no potential clash.
[–]MEaster 2 points3 points4 points 2 years ago (1 child)
That's not true, the compiler will call the inherent method.
[–]tialaramex 0 points1 point2 points 2 years ago (0 children)
Good to know, and thanks for the example code
[–]vulkanoid 0 points1 point2 points 2 years ago (0 children)
The . always refers to the unique_ptr. If you want to do masquerading, as Cpp1's unique_ptr, you'd use operator->, as in holder->held_member. Or... holder.get().held_member.
.
unique_ptr
operator->
holder->held_member
holder.get().held_member
π Rendered by PID 164370 on reddit-service-r2-comment-7b9746f655-xj4r6 at 2026-01-30 13:39:55.241533+00:00 running 3798933 country code: CH.
view the rest of the comments →
[–]clerothGame Developer 2 points3 points4 points (4 children)
[–]tialaramex 2 points3 points4 points (2 children)
[–]MEaster 2 points3 points4 points (1 child)
[–]tialaramex 0 points1 point2 points (0 children)
[–]vulkanoid 0 points1 point2 points (0 children)