[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++



Fredag den 21. april 2006 12:59 skrev Michael Rasmussen:
> On Fri, 21 Apr 2006 12:33:02 +0200, Mads Bondo Dydensborg wrote:
> > Jeg ville gerne begrænse mine erklæringer til at oversætteren kun
> > accepterer const, dvs. af hej_b formen.
> >
> > Nogen bud?
>
> Jeg har lige et opklarende spørgsmål: Er det returværdien, der skal
> være af typen const, eller er det parameteren const std::string & name,
> eller begge dele?

Jeg vil gerne tvinge brugere af min template til at de strenge de sender med 
skal være const.

Så, man ikke kan skrive
std::string hej( "hej" );
osv<int, hej> Osv;
hej = "goddag";

Jeg forstår ikke hvad du mener med returværdien?

>
> For det sidste burde følgende løse problemstillingen:
> template<class T, const std::string & name > const
> class

Det giver følgende (g++ 3.4.4):
 error: `const' can only be specified for objects and functions

What gives?

Mads

-- 
Mads Bondo Dydensborg.                               sslug@sslug
I'm an environmental oxymoron - I buy organic and drive an SUV
                    
		                        - Seen on slashdot.org



 
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] *