Constrained genericity: Difference between revisions

Content deleted Content added
Ce (talk | contribs)
→‎{{header|C++}}: slight mistake in the explanation
Line 85:
}
</cpp>
The difference to a global function <code>void eat(Food const&)</code> is that the function in the concept map is only visible to functions using that concept map, thus reducing namespace polution. Functions directly operating on <code>Food</code> objects can use the interface provided by <code>Food</code> itself, e.g. <code>apple.munch()</code>, or explicitly invoke <code>Eatable<Food>::eat(apple)</code>. Of course, concept maps also work with built-in types:
<cpp>
concept_map Eatable<int>