File: eraseall.yo

package info (click to toggle)
c%2B%2B-annotations 11.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 10,952 kB
  • sloc: cpp: 20,008; makefile: 1,502; ansic: 165; sh: 121; perl: 90
file content (30 lines) | stat: -rw-r--r-- 1,695 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
25
26
27
28
29
30
Erasing all types tt(EraseType) from a tt(TypeList) can easily be accomplished
by applying the erasure procedure not only to the head of the tt(TypeList) but
also to the  tt(TypeList)'s tail.

Here is the algorithm, described in a slightly different order than
tt(Erase)'s algorithm:
    itemization(
    it() If the tt(TypeList) is empty, there's nothing to erase, and an empty
        tt(TypeList) results. This is exactly what we do with tt(Erase), so we
        can use inheritance to prevent us from having to duplicate elements of
        a template meta program:
            verbinclude(//ERASEIDXEMPTY examples/erase.h)
    it() The foundation of the algorithm is therefore a struct template
        tt(EraseAll) expecting the type to erase and a tt(TypeList) that is
        derived from tt(Erase), thus already offering the empty tt(TypeList)
        handling specialization:
            verbinclude(//ERASEALL examples/erase.h)
    it() If tt(TypeList)'s head matches tt(EraseType) tt(EraseAll) is also
        applied to the tt(TypeList)'s tail, thus removing all occurrences of
        tt(EraseType) from tt(TypeList):
            verbinclude(//ERASEALLTYPES examples/erase.h)
    it() In all other cases (i.e., tt(TypeList)'s head does em(not) match
        tt(EraseType)) tt(EraseAll) is applied to the tt(TypeList)'s tail.
        The returned tt(TypeList) consists of the original tt(TypeList)'s
        initial type and the types of the tt(TypeList) returned by the
        recursive tt(EraseAll) call:
            verbinclude(//ERASEALLNEXT examples/erase.h)
    )
    Here is a statement showing how tt(EraseAll) can be used:
       verbinclude(//ERASEALL examples/erase.cc)