Re:Defining interfaces in C++ with ‘concepts’ (C++20)
by gpderetta on Wednesday April 19, 2023 @09:11AM
(#35627706)
It would be extremely hard to implement templates with dynamic dispatch while maintaining the correct semantics.
[ Parent
| on HN ]
Re:Defining interfaces in C++ with ‘concepts’ (C++20)
by foxhill on Wednesday April 19, 2023 @12:08PM
(#35629915)
templates don’t exist after the front end. there is no ABI that allows them to exist in any object file. there is no object file format they could be embedded in, sans a string representation of the source they came from.
extremely hard is underselling it somewhat :)
Re:Defining interfaces in C++ with ‘concepts’ (C++20)
by seanhunter on Wednesday April 19, 2023 @01:37PM
(#35630986)
Right. For starters, from the very beginning C++ has supported function templates which take native types. So you don't even necessarily have any kind of pointer you could add a vtable to even if you wanted to. Then add to that the guarantee[1] about pod types being directly compatible with C which as you say I don't see how it owuld be possible to do.
[1] which has always been strong even before there was an actual ISO/ANSI standard