Torsten Martinsen writes:
 > 
 > If the definition is
 > 
 >     const char null = '\0';
 > 
 > it should (according to Standard C++) be equivalent to 
 > 
 >     #define null '\0'
 > 
 > (i.e., NO copies will be allocated, as the const will be resolved at compile time).
 > 

 If using this in inline char   &String::operator [] (int n) it says:

c++ -DHAVE_CONFIG_H -I. -I. -I../include 
-DDEFAULT_CONFIG_FILE=\"/opt/www/conf/htdig.conf\"             -I../include -I../htlib 
                -I../htnet -I../htcommon                -I../htword             
-I../db/dist -I../db/dist               -I../db/include -I../db/include                
   -I/usr/include  -g -O2 -Wall -c String.cc
htString.h: In method `char & String::operator [](int)':
In file included from String.cc:16:
htString.h:235: warning: conversion from `const char' to `char &' discards const
htString.h:233: warning: reference to local variable `null' returned

That's why I did :

static char null = '\0';

inline char     &String::operator [] (int n)
{
  if(n < 0) n = Length + n;
  if(n >= Length || n < 0) return null;

  return Data[n];
}


        Cheers,

-- 
                Loic Dachary

                ECILA
                100 av. du Gal Leclerc
                93500 Pantin - France
                Tel: 33 1 56 96 09 80, Fax: 33 1 56 96 09 61
                e-mail: [EMAIL PROTECTED] URL: http://www.senga.org/


------------------------------------
To unsubscribe from the htdig3-dev mailing list, send a message to
[EMAIL PROTECTED] containing the single word "unsubscribe" in
the SUBJECT of the message.

Reply via email to