|
Boost Users : |
Subject: [Boost-users] boost::variant construction,assignment
From: Hicham Mouline (hicham_at_[hidden])
Date: 2008-10-09 12:56:49
hello,
class parameters {
public:
parameters();
~parameters();
const R& getR() const;
void setR(const R& rhs);
const V& getV() const;
void setV(const V& rhs);
private:
const R* r_;
const V* v_;
};
R and V are typedefs of variant<>.
I have chosen to make the private members r_ and v_ as pointers to allow for r_=0 and v_=0
(is this a "never do this" thing?).
R setter is implemented like this:
void parameters::setR(const R& rhs) {
if (!r_)
r_ = new R( rhs );
else
*r_ = rhs;
}
then
~parameters()
{
if (r_)
delete r_;
}
There is no operator= for variant<> it seems?
regards,
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