On Mon, 7 Dec 2009, Derek Gaston wrote:
> On Dec 7, 2009, at 10:38 AM, Roy Stogner wrote: > >> >> On Mon, 7 Dec 2009, Derek Gaston wrote: >> >>> Ok - we've tried this out. It was missing a piece of >>> functionality... the ability to take "true" or "false" in as a >>> boolean. We added this back in and committed the new getpot-roy.h. >> >> Thanks. Any idea why the bool case wasn't adequately handled by the >> template? Is it inadvertently upcasting to int or something? I >> needed the const char* overloading to handle memory management of C >> strings, but I thought the rest would work with the generic code. > > Well... I actually just changed our small modification to now do a > proper template specialization. The issue is that you need a > special __convert_to_type for bool so that it looks for "true" or > "false". > > I suspect that the default templated version of __convert_to_type() > was failing to convert a std::string with "true" in it to a bool on > the line that does "in_string >> retval". In which case the default > value gets returned. Ah! Good catch. It looks like you have to pass a boolalpha manipulator to std::istream and descendants before they'll read alphanumeric inputs for booleans. Would you try that (it's my new update) and see if it works? If it doesn't at least pick up "True", "true", "TRUE", and the converse then we'll use a hand-crafted specialization... but although the C++ standard library is pretty anemic, I'd hope it can at least convert strings to bools reliably. > parse_input_file() changed to parse_file().... that's it! > > So, yeah.... that's pretty minor. ;-) Heh, true. But it wasn't an intentional change; I just misread the method name when I was merging some of our forked bits over to the new file! Compatibility with upstream doesn't seem to be an issue here (they only seem to initiate the file parsing in the constructor) so I'll change the name back. --- Roy ------------------------------------------------------------------------------ Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev _______________________________________________ Libmesh-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libmesh-devel
