c++ - What is the difference between c++0x concepts and c# constraints? -


Introduces C ++ 0x concepts , it defines you, basically , A kind of a kind. .

C # allow you specify the constraints of normal with the " " section.

Is there any difference between them?

Thank you.

One thing to keep in mind is that C ++ templates and C # generic are not exactly the same. For more information about the differences see this.

To explain the C ++ 0x concepts, from the page you linked to, it seems like in C ++, you want to be able to specify that the type of template applies some properties In C #, the barrier increases in comparison to that and forces the normal type to be "bound". For example, the following C # code:

  public generic list & lt; T & gt; Where T: IDisposable  

says that any type of usage can be used instead of should apply the IDisposable interface Similar, the following code:

  public abstract class ABC {} public class XYZ: ABC {} public generic list & lt; T & gt; Where T: ABC  

says that any type used in place of T should be obtained from ABC or ABC.

The C ++ 0x concept idea that only the type used in place of T is the same properties as defined by ABC (or IDICspaceable), not that it should be of that type.


Comments