TITLE: Templates reuse source, not executables


[ This example adapted from "C++ Gotchas", tutorial notes by
  Tom Cargill, p. 68. ]


template <class T>
int checksum (T p)
{
    int sum = 0;

    const char* cp = (const char*) p;

    for (int i = 0; i< sizeof (*p); i++)
	sum += cp [i];

    return sum;
}


struct Point
{
    int x;
    int y;
};


int main ()
{
    Point here;

    int s = checksum (&here);
    int u = checksum (&s);

    const Point there = here;

    int t = checksum (&there);

    return 0;
}


A quick check of the loader map reveals that there is code
generated for each expansion (by type) of the template:

	Address		Publics

	000002fd	checksum (Point*)
	00000327	checksum (int*)
	00000355	checksum (const Point*)
