Boost logo

Boost :

From: Johan Torp (johan.torp_at_[hidden])
Date: 2007-05-24 07:56:35


Peter Bindels <dascandy <at> gmail.com> writes:
> If it's a template class, which I strongly suspect it is (and if it's
> the class mentioned above, it is) you can add them all as direct
> forwards which will fail to compile if and only if you try to use them
> without the base class supporting them. I'm not sure how you'd get
> this to work with C++0x concepts though.

Until C++0x concepts are added, we can use boost::concept_check to get a better
compilation error for this case.

As a sidenote:

I think it might be possible to not define the operator at all if we have a type
which doesn't support += if we want to. It'd look something like this:

struct null_base {};
struct operator_plus_equal_base {
  template<T> operator+=(....)
};

template<class T>
class observable_value : public some_mpl_expression<T>::type
{};

where some_mpl_expression is a boost::mpl expression which results in either
null_base or operator_plus_equal_base depending on whether += exists for a given
type T or not.

I suppose that this solution wouldn't add much value, it's just interesting :)

Best Regards, Johan Torp


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk