loic@ceic.com
Mon, 4 Oct 1999 13:53:35 +0200 (MEST)
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 DacharyECILA 100 av. du Gal Leclerc 93500 Pantin - France Tel: 33 1 56 96 09 80, Fax: 33 1 56 96 09 61 e-mail: Loic@Dachary.org URL: http://www.senga.org/
------------------------------------ To unsubscribe from the htdig3-dev mailing list, send a message to htdig3-dev@htdig.org containing the single word "unsubscribe" in the SUBJECT of the message.
This archive was generated by hypermail 2.0b3 on Mon Oct 04 1999 - 04:46:40 PDT