if an interface is a template1 [C++ Core Guidelines] I.9 템플릿으로 만든 인터페이스는 concepts 문법을 사용해서 구체화하자 I.9: If an interface is a template, document its parameters using concepts 이유인터페이스를 구체적으로 작성하여 컴파일 타임에 조건을 검사할 수 있도록 만드는 것이 좋습니다. 예시 (좋은 예)// C++20template requires input_iterator && equality_comparable_with, Val>Iter find(Iter first, Iter last, Val v){ // ... 대략 이터레이터의 first 에서 last 까지 탐색하면서 v 값을 검출하는 코드 ...}Generic porgamming 과 Concepts 문법에 대한 내용을 참고할 수 있습니다. 정리1. requires 문법을 이용하면 템플릿 파.. 2024. 7. 5. 이전 1 다음