c60c-2ca@WEB.berkeley.edu (05/04/90)
While looking at some of the files inside the g++-include
directory, I discovered the following "strange" code:
In "Set.hP" ...
#ifndef _<T>Set_h
#pragma once
#define _<T>Set_h 1
#include <Pix.h>
#include "<T>.defs.h"
class <T>Set
{
private:
int count;
public:
int length();
.... // Some prototype declarations deleted...
virtual <T>& operator() (Pix i) = 0;
virtual Pix seek(<T&> item);
.... // Rest of body
};
There exists a file called "defs.hP" and in it are the followings:
In "defs.hP" ...
#ifndef _<T>defs_h
#pragma once
#define _<T>defs_h 1
// equality operator
#ifndef <T>EQ
#define <T>EQ(a, b) ((a) == (b))
#endif
// Similiar macros for LE, CMP, HASH ...
And for "Pix.h", it contains the following:
In "Pix.h" ...
#ifndef _Pix_h
#pragma once
#define _Pix_h 1
typedef void * Pix;
#endif
As a matter of fact, the extraneous construct "<T> ..."
can be found in all the ".hP" and ".ccP" files under that
directory.
My first impression is that "<T> ..." has something to
do with 'parametrized type capability'. I also thought that
the g++ compiler will perform the necessary pre-processing to
substitue the actual type for T.
However, when I tried to compile a simple program which
includes files "Set.hP" and "Set.ccP", it became evident that
"Set.hP" and "Set.ccP" have to under some pre-processing by a
different pre-processor before they are fed to the g++ compiler.
My questions then are:
1) What is the true meaning of "<T> ..."? Does it really
have something to do with parametrized type?
2) Where can I find the pre-processor necessary to convert
the ".hP" and ".ccP" files to legal C++ programs?
Any suggestion or help is GREATLY appreciated.
Andrew Choi
Internet Address: c60c-2ca@web.berkeley.edu
Standard Disclaimer