Boost logo

Boost :

From: alnsn_at_[hidden]
Date: 2004-07-01 00:16:35

David Abrahams wrote:
> Maybe you should show an example of code where the use of ref/cref
> causes a problem.

using namespace std;
using namespace boost;

template<class T>
reference_wrapper<T const> head(vector<T> const& v)
    return cref(v[0]); // binds with temporary if T == bool

int main()
    bool buf[1] = {};
    vector<bool> v(buf, buf + 1);
    reference_wrapper<bool const> r = head(v);

Similar problem with ref:

int const const_rvalue();
ref(const_rvalue()); // binds with a temporary

Is it possible to protect from this effect at least for ref case?

Alexander Nasonov

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