Boost logo

Boost :

From: Matthew Vogt (mattvogt_at_[hidden])
Date: 2005-03-10 18:25:05

On Thu, 10 Mar 2005 15:36:40 -0700, "Jonathan Turkanis"
<technews_at_[hidden]> 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

// 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; }

    char c;

  character(void) {}
  character(char value) : c(value) {}

  char value(void) const { return c; }

  bool operator_bool(void) const { return good(); }

  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.


  Matthew Vogt

Boost list run by bdawes at, gregod at, cpdaniel at, john at