1

I understand the definition of two templates.
But I don't know under what circumstances this would actually be useful.
Could you show an example code where it is used under what circumstances?

Remark

ysbaekFox
  • 73
  • 6
  • 1
    Often in a function we assume that the input variables have all the default methods (assignment copy, etc), so we would put `semiregular`, if we also wanted equality then we'd put `regular`. I'm stating the obvious here... but that's what they're for. Just look at your function/method, and if it uses the variables' methods in such a way that requires them, then add that `requires`, otherwise don't. – Elliott Nov 15 '21 at 00:21
  • 1
    You mention "templates", but you don't mention the term _concepts_ -- which is what these are. Are you familiar with C++20 concepts, and what makes them useful? If not, are you familiar with SFINAE? – Drew Dormann Nov 15 '21 at 00:26
  • @Drew Dormann I'm not familiar with C++20, and also SFINAE.. I will study that you said, If you recommend to me article? – ysbaekFox Nov 15 '21 at 00:32
  • @ Elliott Thank you, I understand what you are saying. :) – ysbaekFox Nov 15 '21 at 00:34
  • 1
    If you look at the links you provide, these templates are not classes and not functions, they are each a `concept`. You can read up on the purpose of concepts [at this question](https://stackoverflow.com/questions/15669592/what-are-the-differences-between-concepts-and-template-constraints). – Drew Dormann Nov 15 '21 at 00:37

0 Answers0