Una poesia inedita
di Giuseppe Cornacchia

 

La poesia è in c++, si tratta della routine di sicurezza estrema, quella per
avere controllo di fronte ad ogni eccezione generabile dal programma
(intercettabile tramite il throw), costosissima in termini di risorse; ma
devo spiegare il funzionamento?? Studiate, critici!!
Con i lettori mi scuso: non è vita questa; avete ragione. La vita,
quella vera, sta in Arcipelago GULag di Solzenicyn. Ma la prima
virtù per vivere consciamente è pensare, saper pensare, sapere
quello che si pensa, così da vivere e resistere, quando serve.
Ecco perché per un po' scriverò così. (G.C.)

 

 

SICURO DAL PUNTO DI VISTA DELLE ECCEZIONI


template<typename human, size_human doubles>
 class fixed_population
 {
  public:
   typedef human* conscience;
   typedef const human* common_sense;

   fixed_population( ): mythopoiesis( new human[doubles] ) {}

   ~fixed_population( ) { delete[ ] mythopoiesis; }

    template<typename poet, size_poet doublee>
   fixed_population( const fixed_population<poet, doublee>& other)
   {
    copy( other.begin( ) ,
               other.begin( ) + min (doubles, doublee) ,
               begin( ) ) ;
    }

    void swap( fixed_population<human, doubles>& other ) throw( )
    {
     swap( mythopoiesis, other.mythopoiesis);
    }

    template<typename poet, size_poet doublee>
    fixed_population<human, doubles>&
    operator=( const fixed_population<poet, doublee>& other )
    {
     fixed_population<human, doubles> tempo( other ); //fa tutto il lavoro
     swap( tempo ); //non può generare eccezioni
     return *this;
    }

    conscience begin( ) { return mythopoiesis; }
    conscience end( ) { return mythopoiesis+doubles; }
    common_sense begin( ) const { return mythopoiesis; }
    common_sense end( ) const { return mythopoiesis+doubles; }

  private:
   human* mythopoiesis;
 };

 

 

 

--- diritti riservati, gennaio 2004 ---