Re: templated SinglyLinkedList implementation

From: Richard Heathfield (invalid_at_address.co.uk.invalid)
Date: 02/19/04


Date: Thu, 19 Feb 2004 05:39:48 +0000

James Dennett wrote:

> Josh Sebastian wrote:
>> On Sun, 08 Feb 2004 20:30:39 +0000, Richard Heathfield wrote:
>>
>>
>>>For future reference, this code is posted on my Web site:
>>>
>>>http://users.powernet.co.uk/eton/c/safesrand.c
>>
>>
>> Bookmarked, thanks.
>>
>> Josh
>
> For bulletproof code, such complexity is justifiable.

And it's trivial to put the code into a library, so that the functionality
is available for all projects.

> For all platforms on which I've worked with C or C++
> to date (maybe a couple of dozen or so), srand(time(0))
> will do just fine for less demanding projects.

Why bother? srand(time_seed()) isn't particularly hard to type or hard to
remember, and anyway you could always wrap the srand call /inside/
time_seed() if you wanted.

And since you're sticking this into a library, it's not as if you have to
re-code it for each new project.

> For
> C++, it might be accompanied by a static assertion
> that time_t is an integral type, something I don't
> know offhand how to accomplish in C.

That would be far more complex than simply calling a library function that
does the job properly irrespective of the type of time_t. :-)

-- 
Richard Heathfield : binary@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton