Hacker News new | ask | show | jobs
by nly 700 days ago
C++ concepts have the same problem. In practice is a non-issue for the language because templates already had this issue.

In old-school C++ you would probably handle this with traits. I.e. a specialization of a tag type that can be written by either the class author or a third party that indicates a types semantic compatibility with a concept.

Example: specialising std::hash instead of forcing everyone to add hashCode() members

1 comments

And you can implement pseudo-nominal conformance to a concept Foo by requiring the presence of a 'yes_this_class_really_conforms_to_Foo' tag.