Comment

Comment by brtv

> std::box<T> addresses these issues by offering deep copying and automatic garbage collection

This is pretty much impossible when holding a pointer of base class. However, this is a primary reason for having pointers in the first place (polymorphism, and having abstract base classes).

In all other cases, you're probably better off with either the raw value, std::variant or std::reference_wrapper.

parent brtv 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton