1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2024-11-12 21:09:01 +00:00

fix operator=

This commit is contained in:
bolero-MURAKAMI 2013-11-10 18:36:04 +09:00
parent 4677628cd6
commit 1b09c5a672
2 changed files with 38 additions and 15 deletions

View file

@ -17,6 +17,7 @@
#include <sprout/iterator/reverse_iterator.hpp>
#include <sprout/iterator/value_iterator.hpp>
#include <sprout/utility/swap.hpp>
#include <sprout/utility/move.hpp>
namespace sprout {
//
@ -53,6 +54,22 @@ namespace sprout {
explicit SPROUT_CONSTEXPR pit(value_type const& t)
: elem(t)
{}
SPROUT_CXX14_CONSTEXPR pit& operator=(pit const& rhs) {
elem = rhs.elem;
return *this;
}
SPROUT_CXX14_CONSTEXPR pit& operator=(pit&& rhs) {
elem = sprout::move(rhs.elem);
return *this;
}
SPROUT_CXX14_CONSTEXPR pit& operator=(value_type const& rhs) {
elem = rhs;
return *this;
}
SPROUT_CXX14_CONSTEXPR pit& operator=(value_type&& rhs) {
elem = sprout::move(rhs);
return *this;
}
SPROUT_CXX14_CONSTEXPR void swap(pit& other)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(elem, other.elem)))
{

View file

@ -109,7 +109,12 @@ namespace sprout {
impl_difference_type to_first_;
impl_difference_type to_last_;
public:
sub_array_impl() = default;
SPROUT_CONSTEXPR sub_array_impl()
: array_()
, to_first_()
, to_last_()
{}
sub_array_impl(sub_array_impl const&) = default;
protected:
template<typename ContainerTag, sprout::index_t... Indexes>
SPROUT_CONSTEXPR sub_array_impl(
@ -207,6 +212,7 @@ namespace sprout {
public:
// construct/copy/destroy:
sub_array() = default;
sub_array(sub_array const&) = default;
SPROUT_CONSTEXPR sub_array(param_type arr, const_iterator first, const_iterator last)
: impl_type(
array_tag(),
@ -243,6 +249,20 @@ namespace sprout {
other.to_first_ + to_last
)
{}
template<typename Container2>
SPROUT_CXX14_CONSTEXPR sub_array& operator=(sub_array<Container2> const& rhs) {
array_ = rhs.array_;
to_first_ = rhs.to_first_;
to_last_ = rhs.to_last_;
return *this;
}
template<typename Container2>
SPROUT_CXX14_CONSTEXPR sub_array& operator=(sub_array<Container2>&& rhs) {
array_ = sprout::move(rhs.array_);
to_first_ = sprout::move(rhs.to_first_);
to_last_ = sprout::move(rhs.to_last_);
return *this;
}
SPROUT_CXX14_CONSTEXPR void fill(const_reference value) {
sprout::fill_n(begin(), size(), value);
@ -321,20 +341,6 @@ namespace sprout {
return get_array().data() + to_first_;
}
// others:
template<typename Container2>
SPROUT_CXX14_CONSTEXPR sub_array& operator=(sub_array<Container2> const& rhs) {
array_ = rhs.array_;
to_first_ = rhs.to_first_;
to_last_ = rhs.to_last_;
return *this;
}
template<typename Container2>
SPROUT_CXX14_CONSTEXPR sub_array& operator=(sub_array<Container2>&& rhs) {
array_ = sprout::move(rhs.array_);
to_first_ = sprout::move(rhs.to_first_);
to_last_ = sprout::move(rhs.to_last_);
return *this;
}
SPROUT_CXX14_CONSTEXPR pointer c_array() {
return data();
}