Specifications
CAVR-4
Part 1. Using the compiler
Using C++
115
Use this syntax if you want to override both global and class-specific operator new
and
operator delete for any data memory.
Note that there is a special syntax to name the
operator new functions for each
memory, while the naming for the operator delete functions relies on normal
overloading.
New and delete expressions
A new expression calls the operator new function for the memory of the type given. If
a
class, struct, or union type with a class memory is used, the class memory will
determine the operator new function called. For example,
//Calls operator new __near(__near_size_t)
int __tiny *p = new __tiny int;
//Calls operator new __near(__near_size_t)
int __near *q = new int __near;
//Calls operator new[] __data16(__data16_size_t)
int __near *r = new __near int[10];
//Calls operator new __tiny(__tiny_size_t)
class __tiny S{...};
S *s = new S;
A delete expression calls the operator delete function that corresponds to the
argument given. For example,
delete p; //Calls operator delete(void __near *)
delete s; //Calls operator delete(void __tiny *)
Note that the pointer used in a delete expression must have the correct type, that is, the
same type as that returned by the
new expression. If you use a pointer to the wrong
memory, the result might be a corrupt heap. For example,
int __near * t = new __tiny int;
delete t; //Error: Causes a corrupt heap
TE M P L A T E S
Extended EC++ supports templates according to the C++ standard, except for the
support of the export keyword. The implementation uses a two-phase lookup which
means that the keyword
typename has to be inserted wherever needed. Furthermore, at
each use of a template, the definitions of all possible templates must be visible. This
means that the definitions of all templates have to be in include files or in the actual
source file.