Something about sizeof(char)
Paolo Carlini
pcarlini@suse.de
Mon Jun 21 13:41:00 GMT 2004
Dhruv Matani wrote:
>I'm not too good at figuring out whether code is portable or not, so I'm
>not rally sure that this would be acceptable, so I'd like to hear from
>the experts.
>
>
>>ffirst_of(string const& src, string const& f)
>>{
>>#if __CHAR_BIT__ <= 8
>> char table[1 << __CHAR_BIT__] = { 0 };
>> string::size_type sz = f.size();
>> string::size_type i;
>>
>> for (i = 0; i < sz; ++i)
>> table[(unsigned int)f[i]] = 1;
>>
>>
A general problem I can easily see with this kind of idea is that its
profitability
depends way too much on the size of f: what happens when f is big and src is
small? We should work on this issue, first.
Paolo.
More information about the Libstdc++
mailing list