This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Something about sizeof(char)


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]