From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,HEADER_SPAM autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b30bd69fa8f63cb2 X-Google-Attributes: gid103376,public X-Google-Thread: fc772,b30bd69fa8f63cb2 X-Google-Attributes: gidfc772,public X-Google-ArrivalTime: 2003-06-16 01:42:56 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.ems.psu.edu!news.cse.psu.edu!uwm.edu!rpi!not-for-mail From: =?Windows-1252?Q?Terje_Sletteb=F8?= Newsgroups: comp.lang.ada,comp.lang.c++.moderated Subject: Re: C bug of the day Date: 16 Jun 2003 04:45:08 -0400 Organization: unknown Sender: cppmods@netlab.cs.rpi.edu Message-ID: References: <1054751321.434656@master.nyc.kbcfp.com> NNTP-Posting-Host: netlab.cs.rpi.edu X-Original-Date: Sun, 15 Jun 2003 23:34:47 +0200 X-Submission-Address: c++-submit@netlab.cs.rpi.edu X-Auth: PGPMoose V1.1 PGP comp.lang.c++.moderated iQBVAwUAPu2DkEHMCo9UcraBAQGc1gH+JW2gseuqAWv62C8dbKN8MWYQqAJKgFPt u9R+g2k+SPF/grpqHJVuRg+5CbxQ9WOGHVzK+P+VYEW6PxWNXfUC6Q== =xmAl Xref: archiver1.google.com comp.lang.ada:39223 comp.lang.c++.moderated:68432 Date: 2003-06-16T04:45:08-04:00 List-Id: "Francis Glassborow" wrote in message news:jhPtsFBx6F7+EwOv@robinton.demon.co.uk... > In message , Terje Sletteb > writes > >I would be interested to know how read() is implemented. Could you > >posted it? > > Well for what they are worth here is the complete set of overloaded > function templates > > Comments for improving them are very welcome. > > // These templates provide safe input for any type that supports > operator>> > // 1) from console with prompt > > template > in_type read(std::string const & prompt, int max_tries = 3){ > in_type temp; I thought your point was that you avoided the use of uninitialised variables? However, that still happens, here. So maybe your point was that you have a function for providing safe input using streams? (As we've discussed at the ACCU begin-cpp mailing list) Well, that was not what my posting was about. My posting, and what it replied to, was that there may be cases where leaving a variable uninitialised is ok. The same happens in your function (as John Potter also pointed out). I became a little put off, when you wrote: "Well yes, but any halfway competent programmer has a way to initialise a variable from a stream". As I understand, you're talking about safe input, which wasn't what I was discussing, at all. My example was simple on purpose, to show the use with a stream. The same code appears inside your function. Had it been that you wanted to _add_ something to what I said, I'd understood it. But the way you wrote it, made me think that you somehow contradicted what I said about using an uninitialised variable. It appears you just wanted to add something, then. Naturally, anything but toy programs typically use some form of input validation, but like I said, that's not the issue that was being discussed. Regards, Terje [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ]