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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
template < class Map , class CompatibleKey , class CompatibleData >
void use_it ( Map & m ,
const CompatibleKey & key ,
const CompatibleData & data )
{
typedef typename Map :: value_type value_type ;
typedef typename Map :: const_iterator const_iterator ;
m . insert ( value_type ( key , data ) );
const_iterator iter = m . find ( key );
if ( iter != m . end () )
{
assert ( iter -> first == key );
assert ( iter -> second == data );
std :: cout << iter -> première << "->" << iter -> second ;
}
m . effacer ( clé );
}
int principal ()
{
typedef bimap < set_of < std :: string >, set_of < int > > bimap_type ;
bimap_type bm ;
// Carte standard
{
typedef std :: map < std :: string , int > map_type ;
map_type m ;
use_it ( m , "un" , 1 );
}
// Carte Vue gauche
{
typedef bimap_type :: left_map map_type ;
map_type & m = bm . Gauche ;
use_it ( m , "un" , 1 );
}
// Inverse carte standard
{
typedef std :: map < int , std :: string > reverse_map_type ;
reverse_map_type rm ;
use_it ( rm , 1 , "un" );
}
// Carte Vue droite
{
typedef bimap_type :: right_map reverse_map_type ;
reverse_map_type & rm = bm . Droite ;
use_it ( rm , 1 , "un" );
}
retour 0 ;
} |
Partager