1
0
Fork 0
mirror of https://github.com/bolero-MURAKAMI/Sprout synced 2025-02-04 21:33:56 +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/reverse_iterator.hpp>
#include <sprout/iterator/value_iterator.hpp> #include <sprout/iterator/value_iterator.hpp>
#include <sprout/utility/swap.hpp> #include <sprout/utility/swap.hpp>
#include <sprout/utility/move.hpp>
namespace sprout { namespace sprout {
// //
@ -53,6 +54,22 @@ namespace sprout {
explicit SPROUT_CONSTEXPR pit(value_type const& t) explicit SPROUT_CONSTEXPR pit(value_type const& t)
: elem(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_CXX14_CONSTEXPR void swap(pit& other)
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(elem, other.elem))) 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_first_;
impl_difference_type to_last_; impl_difference_type to_last_;
public: public:
sub_array_impl() = default; SPROUT_CONSTEXPR sub_array_impl()
: array_()
, to_first_()
, to_last_()
{}
sub_array_impl(sub_array_impl const&) = default;
protected: protected:
template<typename ContainerTag, sprout::index_t... Indexes> template<typename ContainerTag, sprout::index_t... Indexes>
SPROUT_CONSTEXPR sub_array_impl( SPROUT_CONSTEXPR sub_array_impl(
@ -207,6 +212,7 @@ namespace sprout {
public: public:
// construct/copy/destroy: // construct/copy/destroy:
sub_array() = default; sub_array() = default;
sub_array(sub_array const&) = default;
SPROUT_CONSTEXPR sub_array(param_type arr, const_iterator first, const_iterator last) SPROUT_CONSTEXPR sub_array(param_type arr, const_iterator first, const_iterator last)
: impl_type( : impl_type(
array_tag(), array_tag(),
@ -243,6 +249,20 @@ namespace sprout {
other.to_first_ + to_last 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_CXX14_CONSTEXPR void fill(const_reference value) {
sprout::fill_n(begin(), size(), value); sprout::fill_n(begin(), size(), value);
@ -321,20 +341,6 @@ namespace sprout {
return get_array().data() + to_first_; return get_array().data() + to_first_;
} }
// others: // 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() { SPROUT_CXX14_CONSTEXPR pointer c_array() {
return data(); return data();
} }