[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [PROGRAMMERING] Konstante template argumenter i C++



Hej Mads

Har du kigget på boost TypeTraits. Der er der nogle template hacks til
at sikre at en given type har nogle givne egenskaber.

Det er længe siden jeg kiggede på det, men så vidt jeg husker kan man få
oversætteren til at genere fejl, hvis template argument typen ikke har
en given egenskab, så som const.

Det kan være at det skal gøres sammen med boost StaticAssert

Mvh

Lars Hartmann

Mads Bondo Dydensborg wrote:
> Hej alle
> 
> Er dette en valid c++ erklæring:
> 
>  template<class T, const std::string & name > 
> class osv.
> 
> ?
> 
> Den bliver accepteret af g++ 3.4.4 (peger til eksternt linket objekt, tror 
> jeg). Når jeg vil instantiere kan jeg tilsyneladende give enten en 
> std::string hej_a( "hej" );
> eller
> extern const std::string hej_b( "hej" );
> 
> som i 
> osv<int, hej_a> Hej_a;
> og
> osv<int, hej_b> Hej_b;
> 
> Jeg ville gerne begrænse mine erklæringer til at oversætteren kun accepterer 
> const, dvs. af hej_b formen.
> 
> Nogen bud?
> 
> Mads
> 


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2006-05-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *