98:. However, there is one important difference between concepts and interfaces: when a template parameter is required to implement a particular interface, the matching type can only be a class that implements (explicitly) that interface. Concepts bring more flexibility because they can be satisfied in two ways:
66:
term was introduced to name just a simple description of the requirements for particular type, usually being a template parameter. It was not encoded in the language explicitly – the concept was expressed only by what operations are attempted on objects of that type and what is expected to work (that
109:
But the C# language has several constructs where the used type does not need to explicitly implement a defined interface, it is only required to match the respective pattern (however, these patterns are not called
499:
516:
428:
95:
582:
633:
105:
implicitly defined for "auto concepts", which can be used also for built in types and other types that were not predestined for this use
567:
475:
143:
87:
652:
83:
136:
102:
explicitly defined as satisfied by using a concept map (defined separately to the type itself, unlike interfaces)
44:
28:
120:
iteration statement allows the iterated object to be of any type, as long as it implements an appropriate
613:
20:
52:
563:
534:
630:
433:
91:
68:
438:
637:
464:
Generic programming and the STL: using and extending the C++ Standard
Template Library
646:
608:
32:
593:
115:
47:, as this was one of the first libraries that extensively used templates. The term
487:
618:
231:
Many algorithms rely on these properties to function properly. For example the
624:
443:
147:
139:
implements concepts as a series of arbitrary compile-time boolean predicates.
76:
72:
31:, including syntax and semantics. In this way, concepts are related to
391:, the following are valid expressions with corresponding semantics:
142:
Another language implementing something very similar to concepts is
59:
174:
is a binary predicate and satisfies the following properties:
476:
a bit of background for concepts and C++17—Bjarne
Stroustrup
619:
Concepts: Linguistic
Support for Generic Programming in C++
235:
function can be safely defined on totally ordered types:
166:
The total ordering concept describes the semantics of the
583:
Total
Orderings - Efficient Programming with Components
128:
statement which requires the resource to implement the
67:
is, to compile correctly). There was a proposal to add
631:
A comparison of C++ concepts and
Haskell type classes
35:
but concepts do not require a subtype relationship.
383:satisfies the Trivial Iterator concept in C++, and
79:eventually accepted the refined design of concept.
354:// !(b < a) implies a == b or a < b
27:is a description of supported operations on a
8:
562:. Addison-Wesley Professional. p. 49.
94:, the role of concepts there is played by
170:operator. A type is totally ordered when
75:, though it was rejected as "not ready".
43:The term was in use as early as 1998 for
51:(and its popularization) is credited to
455:
625:Doug Gregor talk on Concepts at Google
429:Protocol (object-oriented programming)
490:, by Bjarne Stroustrup | Jan 21, 2016
478:, by Bjarne Stroustrup | Feb 26, 2016
7:
609:Boost Generic Programming Techniques
71:as an explicit language feature in
55:, the primary designer of the STL.
14:
404:must be convertible to some type
90:have some similarities to C++'s
146:, where the feature is called
1:
558:Stepanov, Alexander (2009).
535:"Nim Experimental Features"
669:
518:C# 6.0 draft specification
501:C# 6.0 draft specification
124:method. (Compare with the
237:
137:Nim programming language
560:Elements of Programming
505:The foreach statement
398:default construction.
653:Generic programming
522:The using statement
312:// < is defined.
204:anti-symmetric: If
62:1998 standard, the
21:generic programming
16:MnrJvanSouth Africa
636:2017-08-09 at the
130:System.IDisposable
53:Alexander Stepanov
660:
596:
594:Trivial Iterator
591:
585:
580:
574:
573:
555:
549:
548:
546:
545:
531:
525:
514:
508:
497:
491:
485:
479:
473:
467:
466:. 1998. pp 17–18
460:
439:Interface (Java)
417:
413:
407:
403:
397:
390:
386:
382:
370:
367:
364:
361:
358:
355:
352:
349:
346:
343:
340:
337:
334:
331:
328:
325:
322:
319:
316:
313:
310:
307:
304:
301:
298:
295:
292:
289:
286:
283:
280:
277:
274:
271:
268:
265:
262:
259:
256:
253:
250:
247:
244:
243:<concepts>
241:
234:
226:
222:
218:
211:
207:
200:
196:
192:
185:
181:
178:anti-reflexive:
173:
169:
131:
127:
123:
118:
668:
667:
663:
662:
661:
659:
658:
657:
643:
642:
638:Wayback Machine
605:
600:
599:
592:
588:
581:
577:
570:
557:
556:
552:
543:
541:
533:
532:
528:
515:
511:
498:
494:
486:
482:
474:
470:
461:
457:
452:
425:
415:
411:
405:
401:
395:
388:
384:
380:
377:
372:
371:
368:
365:
362:
359:
356:
353:
350:
347:
344:
341:
338:
335:
332:
329:
326:
323:
320:
317:
314:
311:
308:
305:
302:
299:
296:
293:
290:
287:
284:
281:
278:
275:
272:
270:totally_ordered
269:
266:
263:
260:
257:
254:
251:
248:
245:
242:
239:
232:
224:
220:
216:
209:
205:
198:
194:
190:
189:transitive: If
183:
179:
171:
167:
164:
159:
153:
129:
125:
121:
116:
82:As generics in
41:
17:
12:
11:
5:
666:
664:
656:
655:
645:
644:
641:
640:
628:
622:
614:Douglas Gregor
611:
604:
603:External links
601:
598:
597:
586:
575:
568:
550:
526:
509:
492:
480:
468:
462:Austern, M.H.
454:
453:
451:
448:
447:
446:
441:
436:
434:Concepts (C++)
431:
424:
421:
420:
419:
409:
399:
376:
373:
238:
229:
228:
213:
202:
187:
182:for any value
163:
162:Total ordering
160:
158:
155:
107:
106:
103:
40:
37:
33:abstract types
15:
13:
10:
9:
6:
4:
3:
2:
665:
654:
651:
650:
648:
639:
635:
632:
629:
626:
623:
621:
620:
615:
612:
610:
607:
606:
602:
595:
590:
587:
584:
579:
576:
571:
569:9780321635372
565:
561:
554:
551:
540:
536:
530:
527:
524:
523:
519:
513:
510:
507:
506:
502:
496:
493:
489:
488:Alex Stepanov
484:
481:
477:
472:
469:
465:
459:
456:
449:
445:
442:
440:
437:
435:
432:
430:
427:
426:
422:
410:
400:
394:
393:
392:
374:
236:
214:
203:
188:
177:
176:
175:
161:
156:
154:
151:
149:
145:
140:
138:
133:
122:GetEnumerator
119:
113:
104:
101:
100:
99:
97:
93:
89:
85:
80:
78:
74:
70:
65:
61:
56:
54:
50:
46:
38:
36:
34:
30:
26:
22:
617:
589:
578:
559:
553:
542:. Retrieved
539:nim-lang.org
538:
529:
521:
517:
512:
504:
500:
495:
483:
471:
463:
458:
414:is valid if
378:
230:
165:
152:
148:type classes
141:
134:
132:interface.)
114:). E.g. the
111:
108:
81:
63:
57:
48:
42:
39:Language use
24:
18:
387:is of type
217:a != b
210:!(b < a)
180:!(a < a)
544:2023-06-19
450:References
444:Type class
379:If a type
215:total: If
96:interfaces
616:, et al.
92:templates
647:Category
634:Archived
423:See also
375:Iterator
261:requires
252:typename
246:template
240:#include
225:b < a
221:a < b
206:a < b
199:a < c
195:b < c
191:a < b
157:Examples
112:concepts
69:concepts
627:(video)
412:i->m
144:Haskell
117:foreach
64:Concept
58:In the
49:concept
25:concept
566:
416:(*i).m
357:return
336:return
219:then
208:then
197:then
126:using
77:C++20
73:C++11
564:ISBN
348:else
324:<
279:>
273:<
258:>
249:<
193:and
172:<
168:<
135:The
86:and
84:Java
29:type
23:, a
418:is.
396:I i
285:min
264:std
233:min
223:or
60:C++
45:STL
19:In
649::
537:.
520:,
503:,
402:*i
315:if
267:::
150:.
88:C#
572:.
547:.
408:.
406:T
389:I
385:i
381:I
369:}
366:}
363:;
360:a
351:{
345:}
342:;
339:b
333:{
330:)
327:a
321:b
318:(
309:{
306:)
303:b
300:T
297:,
294:a
291:T
288:(
282:T
276:T
255:T
227:.
212:.
201:.
186:.
184:a
Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.