Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2004-09-16 14:15:25


From: David Abrahams <dave_at_[hidden]>
> Rob Stewart <stewart_at_[hidden]> writes:
> > From: "Neal D. Becker" <nbecker_at_[hidden]>
> >>
> >> template<class T>
> >> inline T& lvalue_cast (const T& rvalue) {
> >> return const_cast<T&> (rvalue);
> >> }
> >
> > That's just a different spelling of const_cast. To make it
> > useful, you need to make it more generic:
> >
> > template <typename T>
> > inline T &
> > lvalue_cast(T & value_i)
> > {
> > return value_i;
> > }
> >
> > That, of course, permits you to silently cast away the const-ness
> > of const lvalues.
>
> That's news to me. AFAICT it's totally safe, but it doesn't work
> with rvalues, which sort of undermines the whole thing.

I didn't make it clear, I see now, but I meant adding the
overload so that both rvalues and lvalues could be passed through
lvalue_cast to get an lvalue.

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

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