Boost logo

Boost Users :

Subject: [Boost-users] boost::variant construction,assignment
From: Hicham Mouline (hicham_at_[hidden])
Date: 2008-10-09 12:56:49


class parameters {

 const R& getR() const;
 void setR(const R& rhs);

 const V& getV() const;
 void setV(const V& rhs);
 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 );
    *r_ = rhs;

 if (r_)
   delete r_;

There is no operator= for variant<> it seems?


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at