News for hackers. Stuff that matters.
Re:Concepts: The Future of Generic Programming [pdf] by ambrop7 on Wednesday December 21, 2016 @12:46PM (#13231020)
I've taken a quick look at current C++ concepts, but from what I understand, they have the following problems considering what I would like to see in C++:

- Weird syntax, the requires thing. I should be able to write a "static interface" in much the same way that I can write pure virtual functions, that is a bunch of functions.

- Ideally one could write the same "interface" and use it either statically (just checking a specific type) or dynamically (vtable calls).

- It is not verified at compile time that the code is using ONLY the defined interface and not something else accidentally.

I really think C++ should go toward something like Rust traits, which work pretty much like what I described above.

Actually in C# interfaces and generics work similarly, save for the fact that they cannot generally do static dispatch, just static verification. In a C# generic method it is not possible to use features of a generic type other than those implied by the "where" constraints.

EDIT: Here's my quick hacky "implementation" of static interfaces in C++. http://ideone.com/yPaZ17

There are no comments on this comment yet.