Ignore:
Timestamp:
Oct 19, 2020, 4:33:47 AM (12 months ago)
Author:
Peter
Message:

Implement move constructo and move-assignment operator for
DiscreteGeneral? (closes #964). Using swap idiom also for
copy-assignment as it gives stronger exception safety, i.e., if
preproc throws, lhs is not modified (whereas before ::p_ was).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/yat/random/random.h

    r4009 r4010  
    363363    DiscreteGeneral(const DiscreteGeneral&);
    364364
     365    /**
     366       \brief Move constructor
     367
     368       \since New in yat 0.19
     369     */
     370    DiscreteGeneral(DiscreteGeneral&&);
     371
    365372    ///
    366373    /// @brief Destructor
     
    385392    DiscreteGeneral& operator=(const DiscreteGeneral&);
    386393
     394    /**
     395       \brief Move assignment operator
     396
     397       \since New in yat 0.19
     398     */
     399    DiscreteGeneral& operator=(DiscreteGeneral&&);
     400
    387401  private:
    388402    void free(void);
     
    391405    gsl_ran_discrete_t* gen_;
    392406    std::vector<double> p_;
    393   };
     407    friend void swap(DiscreteGeneral& lhs, DiscreteGeneral& rhs);
     408  };
     409
     410  /**
     411     \relates DiscreteGeneral
     412
     413     \since Specialisation new in yat 0.19
     414   */
     415  void swap(DiscreteGeneral& lhs, DiscreteGeneral& rhs);
    394416
    395417  /**
Note: See TracChangeset for help on using the changeset viewer.