mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
add bitset operator=()
This commit is contained in:
parent
9c37deb7d7
commit
d386893a74
3 changed files with 60 additions and 6 deletions
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <sstream>
|
||||
#include <sprout/bitset.hpp>
|
||||
#include <sprout/utility/move.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
|
@ -21,6 +22,19 @@ namespace testspr {
|
|||
|
||||
// 20.5.2 bitset operations:
|
||||
|
||||
// operator=
|
||||
{
|
||||
auto bits = bitset_t(0xDEADBACE);
|
||||
bits = bits1;
|
||||
TESTSPR_ASSERT(bits == bits1);
|
||||
}
|
||||
{
|
||||
auto bits2 = bits1;
|
||||
auto bits = bitset_t(0xDEADBACE);
|
||||
bits = sprout::move(bits2);
|
||||
TESTSPR_ASSERT(bits == bits1);
|
||||
}
|
||||
|
||||
// operator&=
|
||||
{
|
||||
auto bits = bits1;
|
||||
|
|
|
@ -23,10 +23,13 @@
|
|||
#include <sprout/algorithm/equal.hpp>
|
||||
#include <sprout/algorithm/fixed/transform.hpp>
|
||||
#include <sprout/algorithm/fixed/fill.hpp>
|
||||
#include <sprout/algorithm/cxx14/copy.hpp>
|
||||
#include <sprout/algorithm/cxx14/move.hpp>
|
||||
#include <sprout/algorithm/cxx14/fill.hpp>
|
||||
#include <sprout/numeric/accumulate.hpp>
|
||||
#include <sprout/operation/fixed/set.hpp>
|
||||
#include <sprout/utility/forward.hpp>
|
||||
#include <sprout/utility/move.hpp>
|
||||
#include <sprout/bit/operation.hpp>
|
||||
#include <sprout/math/comparison.hpp>
|
||||
#include HDR_FUNCTIONAL_SSCRISK_CEL_OR_SPROUT
|
||||
|
@ -227,6 +230,7 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR base_bitset() SPROUT_NOEXCEPT
|
||||
: w_()
|
||||
{}
|
||||
base_bitset(base_bitset<N> const&) = default;
|
||||
SPROUT_CONSTEXPR base_bitset(unsigned long long val) SPROUT_NOEXCEPT
|
||||
: w_{word_type(val), word_type(val >> (CHAR_BIT * sprout::detail::sizeof_<unsigned long>::value))}
|
||||
{}
|
||||
|
@ -234,6 +238,14 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR base_bitset(sprout::detail::base_bitset_from_words_construct_tag, Words... words)
|
||||
: w_{words...}
|
||||
{}
|
||||
SPROUT_CXX14_CONSTEXPR base_bitset<N>& operator=(base_bitset<N> const& rhs) {
|
||||
sprout::copy(rhs.w_ + 0, rhs.w_ + N, w_ + 0);
|
||||
return *this;
|
||||
}
|
||||
SPROUT_CXX14_CONSTEXPR base_bitset<N>& operator=(base_bitset<N>&& rhs) {
|
||||
sprout::move(rhs.w_ + 0, rhs.w_ + N, w_ + 0);
|
||||
return *this;
|
||||
}
|
||||
|
||||
SPROUT_CXX14_CONSTEXPR void
|
||||
setword(std::size_t pos, word_type word) SPROUT_NOEXCEPT {
|
||||
|
@ -506,12 +518,21 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR base_bitset() SPROUT_NOEXCEPT
|
||||
: w_(0)
|
||||
{}
|
||||
base_bitset(base_bitset<1> const&) = default;
|
||||
SPROUT_CONSTEXPR base_bitset(unsigned long long val) SPROUT_NOEXCEPT
|
||||
: w_(val)
|
||||
{}
|
||||
SPROUT_CONSTEXPR base_bitset(sprout::detail::base_bitset_from_words_construct_tag, word_type word)
|
||||
: w_(word)
|
||||
{}
|
||||
SPROUT_CXX14_CONSTEXPR base_bitset<1>& operator=(base_bitset<1> const& rhs) {
|
||||
w_ = rhs.w_;
|
||||
return *this;
|
||||
}
|
||||
SPROUT_CXX14_CONSTEXPR base_bitset<1>& operator=(base_bitset<1>&& rhs) {
|
||||
w_ = sprout::move(rhs.w_);
|
||||
return *this;
|
||||
}
|
||||
|
||||
SPROUT_CXX14_CONSTEXPR void
|
||||
setword(std::size_t, word_type word) SPROUT_NOEXCEPT {
|
||||
|
@ -683,8 +704,15 @@ namespace sprout {
|
|||
}
|
||||
public:
|
||||
SPROUT_CONSTEXPR base_bitset() SPROUT_NOEXCEPT {}
|
||||
base_bitset(base_bitset<0> const&) = default;
|
||||
SPROUT_CONSTEXPR base_bitset(unsigned long long) SPROUT_NOEXCEPT {}
|
||||
SPROUT_CONSTEXPR base_bitset(sprout::detail::base_bitset_from_words_construct_tag) {}
|
||||
SPROUT_CXX14_CONSTEXPR base_bitset<0>& operator=(base_bitset<0> const& rhs) SPROUT_NOEXCEPT {
|
||||
return *this;
|
||||
}
|
||||
SPROUT_CXX14_CONSTEXPR base_bitset<0>& operator=(base_bitset<0>&& rhs) SPROUT_NOEXCEPT {
|
||||
return *this;
|
||||
}
|
||||
|
||||
SPROUT_CXX14_CONSTEXPR void
|
||||
setword(std::size_t, word_type) SPROUT_NOEXCEPT {}
|
||||
|
@ -699,9 +727,8 @@ namespace sprout {
|
|||
|
||||
SPROUT_CXX14_CONSTEXPR word_type
|
||||
getword(std::size_t, bool c = false) SPROUT_NOEXCEPT {
|
||||
// typedef word_type* type;
|
||||
return !c ? 0
|
||||
: throw std::out_of_range("base_bitset::getword"), 0
|
||||
: throw std::out_of_range("base_bitset::getword")
|
||||
;
|
||||
}
|
||||
SPROUT_CONSTEXPR word_type
|
||||
|
@ -1074,7 +1101,10 @@ namespace sprout {
|
|||
}
|
||||
public:
|
||||
// 20.5.1 constructors:
|
||||
SPROUT_CONSTEXPR bitset() SPROUT_NOEXCEPT {}
|
||||
SPROUT_CONSTEXPR bitset() SPROUT_NOEXCEPT
|
||||
: base_type()
|
||||
{}
|
||||
bitset(bitset<N> const&) = default;
|
||||
SPROUT_CONSTEXPR bitset(unsigned long long val) SPROUT_NOEXCEPT
|
||||
: base_type(sprout::detail::sanitize_val<N>::do_sanitize_val(val))
|
||||
{}
|
||||
|
@ -1126,6 +1156,16 @@ namespace sprout {
|
|||
}
|
||||
// 20.5.2 bitset operations:
|
||||
SPROUT_CXX14_CONSTEXPR bitset<N>&
|
||||
operator=(bitset<N> const& rhs) {
|
||||
base_type::operator=(rhs);
|
||||
return *this;
|
||||
}
|
||||
SPROUT_CXX14_CONSTEXPR bitset<N>&
|
||||
operator=(bitset<N>&& rhs) {
|
||||
base_type::operator=(sprout::move(rhs));
|
||||
return *this;
|
||||
}
|
||||
SPROUT_CXX14_CONSTEXPR bitset<N>&
|
||||
operator&=(bitset<N> const& rhs) SPROUT_NOEXCEPT {
|
||||
this->do_and(rhs);
|
||||
return *this;
|
||||
|
|
|
@ -221,6 +221,9 @@ namespace sprout {
|
|||
private:
|
||||
holder_type val;
|
||||
item_holder_type next;
|
||||
private:
|
||||
item& operator=(item const&) SPROUT_DELETED_FUNCTION_DECL
|
||||
item& operator=(item&&) SPROUT_DELETED_FUNCTION_DECL
|
||||
private:
|
||||
item(item const&) = default;
|
||||
SPROUT_CONSTEXPR item(typename holder_type::argument_type p, item_holder_type const& n)
|
||||
|
@ -232,9 +235,6 @@ namespace sprout {
|
|||
, next(n)
|
||||
{}
|
||||
|
||||
item& operator=(item const&) = default;
|
||||
item& operator=(item&&) = default;
|
||||
|
||||
SPROUT_CXX14_CONSTEXPR void swap(item& other)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(sprout::swap(val, other.val)) && SPROUT_NOEXCEPT_EXPR(sprout::swap(next, other.next)))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue