diff options
| author | Howard Hinnant <hhinnant@apple.com> | 2010-10-13 14:37:09 +0000 |
|---|---|---|
| committer | Howard Hinnant <hhinnant@apple.com> | 2010-10-13 14:37:09 +0000 |
| commit | e79d71e2e3e5dbe8883892257b807064d42dbf82 (patch) | |
| tree | f70fe20eb45e6113d76739c3dfaf4f4181d4f3f7 /libcxx | |
| parent | 8ea9b0eb325cdbaa7197c9da588ab83ecdae1e12 (diff) | |
| download | bcm5719-llvm-e79d71e2e3e5dbe8883892257b807064d42dbf82.tar.gz bcm5719-llvm-e79d71e2e3e5dbe8883892257b807064d42dbf82.zip | |
Patch by Marshall Clow to make the assignment operators of piecewise_constant_distribution and piecewise_linear_distribution exception safe.
llvm-svn: 116404
Diffstat (limited to 'libcxx')
| -rw-r--r-- | libcxx/include/random | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/libcxx/include/random b/libcxx/include/random index 5a74f639bd8..6bbde2216fc 100644 --- a/libcxx/include/random +++ b/libcxx/include/random @@ -5938,6 +5938,7 @@ public: template<class _UnaryOperation> param_type(size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw); + param_type & operator=(const param_type& __rhs); _LIBCPP_INLINE_VISIBILITY vector<result_type> intervals() const {return __b_;} @@ -6048,6 +6049,23 @@ public: }; template<class _RealType> +typename piecewise_constant_distribution<_RealType>::param_type & +piecewise_constant_distribution<_RealType>::param_type::operator= + (const param_type& __rhs) +{ +// These can throw + __b_.reserve (__rhs.__b_.size ()); + __densities_.reserve(__rhs.__densities_.size()); + __areas_.reserve (__rhs.__areas_.size()); + +// These can not throw + __b_ = __rhs.__b_; + __densities_ = __rhs.__densities_; + __areas_ = __rhs.__areas_; + return *this; +} + +template<class _RealType> void piecewise_constant_distribution<_RealType>::param_type::__init() { @@ -6239,7 +6257,8 @@ public: template<class _UnaryOperation> param_type(size_t __nw, result_type __xmin, result_type __xmax, _UnaryOperation __fw); - + param_type & operator=(const param_type& __rhs); + _LIBCPP_INLINE_VISIBILITY vector<result_type> intervals() const {return __b_;} _LIBCPP_INLINE_VISIBILITY @@ -6349,6 +6368,24 @@ public: }; template<class _RealType> +typename piecewise_linear_distribution<_RealType>::param_type & +piecewise_linear_distribution<_RealType>::param_type::operator= + (const param_type& __rhs) +{ +// These can throw + __b_.reserve (__rhs.__b_.size ()); + __densities_.reserve(__rhs.__densities_.size()); + __areas_.reserve (__rhs.__areas_.size()); + +// These can not throw + __b_ = __rhs.__b_; + __densities_ = __rhs.__densities_; + __areas_ = __rhs.__areas_; + return *this; +} + + +template<class _RealType> void piecewise_linear_distribution<_RealType>::param_type::__init() { |

