C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Language support for type erasure

From: Thiago Macieira <thiago_at_[hidden]>
Date: Mon, 13 Apr 2026 07:54:14 -0700
On Monday, 13 April 2026 06:04:08 Pacific Daylight Time Marcin Jaczewski via
Std-Proposals wrote:
> But if `print_name` was a more complicated function, like 50 lines?
> you would duplicate it too?
> It could be that calling current `print_name` was an implicit
> requirement, but thinking out of the box sometimes is the right thing.

Make the print_name(Animal) "base" implementation a template, which the two
concrete functions call at their appropriate points.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-04-13 14:54:18