Boost Users :
Subject: Re: [Boost-users] [optional]
From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2009-05-06 12:55:44
2009/5/6 dariomt <dariomt_at_[hidden]>
> Roman Perepelitsa <roman.perepelitsa <at> gmail.com> writes:
> > 2009/5/6 Roman Perepelitsa <roman.perepelitsa <at> gmail.com>
> > It's less efficient, because all arguments will be copied. It's also more
> typing, longer compilation times and more code generated.
> > There is one more caveat. This approach does not work with polymorphic
> (you'll get slicing). I don't think there are any advantages in passing
> boost::optional<T> compared to const T*.Roman Perepelitsa.
> Thanks for the answer!
> Is there a way to avoid the copy (and thus the slicing)? Perhaps using
> boost::optional<T&> or boost::optional< boost::reference_wrapper<T> > ?
You can use boost::optional<T&>, but it's a rather strange beast and it acts
a bit differently from normal optional values.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net