Atmel CAVR-4 Manual De Usuario

Descargar
Página de 323
CAVR-4
Part 1. Using the compiler
Using C++
117
For templates that are matched using this modified algorithm, it is impossible to get 
automatic generation of special code for pointers to small memory types. For large and 
“other” memory types (memory that cannot be pointed to by a default pointer) it is 
possible. In order to make it possible to write templates that are fully 
memory-aware—in the rare cases where this is useful—use the 
#pragma
 
basic_template_matching
 directive in front of the template function declaration. 
That template function will then match without the modifications described above.
Example
#pragma basic_template_matching
template<typename T> void fun(T *);
fun((int _ _near *) 0); // T = int _ _near
Non-type template parameters
It is allowed to have a reference to a memory type as a template parameter, even if 
pointers to that memory type are not allowed.
Example
extern int _ _io x;
template<_ _io int &y>
void foo() 
  y = 17; 
}
void bar() 
{
  foo<x>();
}
The standard template library 
The STL (standard template library) delivered with the product is tailored for Extended 
EC++, as described in IAR Extended Embedded C++, page 110.
The containers in the STL, like 
vector
 and 
map
, are memory attribute aware. This 
means that a container can be declared to reside in a specific memory type which has the 
following consequences:
The container itself will reside in the chosen memory
Allocations of elements in the container will use a heap for the chosen memory
All references inside it use pointers to the chosen memory.