C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Generic code, not the API you are looking for

From: Zhihao Yuan <zy_at_[hidden]>
Date: Sun, 21 Aug 2022 07:11:27 +0000
On Saturday, August 20th, 2022 at 10:04 PM, Sebastian Wittmeier <wittmeier_at_[hidden]> wrote:


> isn't the aim (or one of it) of generic programming to use function templates as a function and especially class templates as a class?

Alexander Stepanov, the person who coinedthe term "generic programming," has
emphasized many times: generic programming
is not about how to use templates. The first
version of STL is done in Scheme. Generic
programming is an idea, templates is only a
way to approach this idea.

> You say, a "protocol" is a function in a truer sense than a template function. In what ways and where is this useful?


The top of the thread pointed out that a
function template, given the recent efforts
of improvements, still does not look like
normal code. A function that takes type
parameter declared with a protocol not only
looks like "normal code," it has to look like
normal code. It can also support separate
compilation, in other words, builds like
normal code.

--Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________

Received on 2022-08-21 07:11:36