
1 Jul
2004
1 Jul
'04
5:16 a.m.
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