File: erasefirst.yo

package info (click to toggle)
c%2B%2B-annotations 13.02.02-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,576 kB
  • sloc: cpp: 25,297; makefile: 1,523; ansic: 165; sh: 126; perl: 90; fortran: 27
file content (24 lines) | stat: -rw-r--r-- 1,370 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
To erase the first occurrence of a specified tt(EraseType) from a tt(TypeList)
a recursive algorithm is used once again. The template meta program uses a
generic tt(Erase) struct and several specializations. The specializations
define a type tt(List) containing the resulting tt(TypeList) after the
erasure. Here is the algorithm:
    itemization(
    it() The foundation of the algorithm consists of a struct template
tt(Erase) expecting the type to erase and a tt(TypeList):
            verbinclude(//ERASEPLAIN examples/erase.h)
    it() If the typelist is empty, there's nothing to erase, and an empty
        tt(TypeList) results:
            verbinclude(//ERASEEMPTY examples/erase.h)
    it() If the tt(TypeList)'s head matches the type to erase, then tt(List)
        becomes a tt(TypeList) containing the original tt(TypeList)'s tail
        types:
            verbinclude(//ERASEHEAD examples/erase.h)
    it() In all other cases the erase operation is applied to the
        tt(TypeList)'s tail. This results in a tt(TypeList) to which the
        orginal tt(TypeList)'s head must be prefixed. The tt(TypeList)
        returned by the prefix operation is then returned as tt(Erase::List):
            verbinclude(//ERASENEXT examples/erase.h)
    )
    Here is a statement showing how tt(Erase) can be used:
            verbinclude(//ERASE examples/erase.cc)