|
Boost : |
Subject: Re: [boost] [optional] memory use for optional refs and ptrs
From: Nevin Liber (nevin_at_[hidden])
Date: 2010-10-06 14:21:38
On 6 October 2010 02:56, Rutger ter Borg <rutger_at_[hidden]> wrote:
> Although [references aren't] the most important case for me, it has its own section in
> the documentation, and I will probably be using lots of these.
Why? What is the advantage over using a raw pointer?
> What also
> doesn't seem right to me is that, e.g.,
>
> struct A {
> int a;
> double b;
> double c;
> std::string d;
> };
>
> struct B {
> boost::optional< int > a;
> boost::optional< double > b;
> boost::optional< double > c;
> boost::optional< std::string > d;
> };
What bit pattern can be used for an int which says it hasn't been set?
Optional models "the variable is not set." You want something
different. Why not just create a different class to model what you
want?
-- Nevin ":-)" Liber <mailto:nevin_at_[hidden]> (847) 691-1404
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk