Boost logo

Boost :

Subject: Re: [boost] [rfc] rcpp
From: Ivan Sorokin (sorokin_at_[hidden])
Date: 2010-02-28 03:50:38

Daniel Trebbien wrote:
>> I have a small library that is intended for convenient and declarative
>> resource wrappers creation.
>> Read Documentation:
>> Main Page:
> What is the safe_bool stuff for; or, why have you implemented
> `operator sb_type() const` rather than `operator bool() const` for
> evaluating a `resource` as a `bool`?

struct T
   operator bool();

void f()
   T a, b;
   a + b; // correct (convert to bool and add)
   a * b; // as well
   a / b;
   a < b;

I want to have possibility to write objects of my class under if and
while, but without addition, multiplication, etc

So instead of operator bool I use operator to member-function.

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