C++ Logo

std-proposals

Advanced search

Re: [std-proposals] cout << any

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Thu, 5 Jan 2023 12:53:30 -0500
On Thu, Jan 5, 2023 at 12:31 PM Marcin Jaczewski via Std-Proposals <
std-proposals_at_[hidden]> wrote:

>
> Is even `std::any` a correct type erasure abstraction in this case?
> if you want some arbitrary object and do some operations on it (`<<`
> is only special case there)
> then should
> https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p0957r5.pdf
> be a better match?
>

Even better:
https://quuxplusone.github.io/blog/2020/11/24/type-erased-printable/

We do not need to — and should not — put anything like this in the
Standard. It's got way too many "design knobs" (copyable? movable?
immovable? short-buffer-optimized? in-place? trivially copyable? trivially
relocatable?...), it is not a vocabulary type, and it is easy for any C++
programmer to write by hand when they need it.

–Arthur

Received on 2023-01-05 17:53:44