
On Thu, 10 Mar 2005 15:36:40 -0700, "Jonathan Turkanis" <technews@kangaroologic.com> said:
I just verified that Borland 5.6.4 complains of ambiguity when safe-bool and char conversions are combined. The same is true with a void* conversion instead of safe-bool. It works with a bool conversion instead of safe-bool, but this makes me a bit nervous. I'll have to wait until I have a bunch of filters implemented.
I realise this is getting out of hand, but you get can around this with two layers of implicit conversion :) Like this (I know the real code is templated, this is just illustration): // return type for boost::io::get struct character : public boost::spirit::safe_bool<character> { // return type for filter::get struct value_type { value_type(const character& src) : c(src.value()) {} operator char() const { return c; } private: char c; }; character(void) {} character(char value) : c(value) {} char value(void) const { return c; } bool operator_bool(void) const { return good(); } private: char c; }; struct some_filter // details ommitted { template<typename Source> character::value_type get(Source& src) { character c; if (c = boost::io::get(src)) { // c is good() }; return c; } }; void user_func(void) { char c = get(some_source); } Obviously, this is getting further and further and from the original code, but only in terms of comprehension. The filter code itself remains transparent. Matt -- Matthew Vogt mattvogt@warpmail.net