mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2024-12-23 21:25:49 +00:00
fix string test
This commit is contained in:
parent
b78911e5b1
commit
117ab52460
3 changed files with 29 additions and 18 deletions
|
@ -89,8 +89,14 @@ namespace testspr {
|
|||
// data
|
||||
TESTSPR_BOTH_ASSERT(carr[0] == *arr1.data());
|
||||
TESTSPR_BOTH_ASSERT(carr[0] == *arr2.data());
|
||||
{
|
||||
auto arr = arr1;
|
||||
TESTSPR_ASSERT(carr[0] == *arr.data());
|
||||
}
|
||||
|
||||
// c_array
|
||||
TESTSPR_BOTH_ASSERT(carr[0] == *arr1.c_array());
|
||||
TESTSPR_BOTH_ASSERT(carr[0] == *arr2.c_array());
|
||||
{
|
||||
auto arr = arr1;
|
||||
TESTSPR_ASSERT(carr[0] == *arr.c_array());
|
||||
|
|
|
@ -299,7 +299,7 @@ namespace testspr {
|
|||
|
||||
// operator+
|
||||
{
|
||||
#ifdef SPROUT_CONFIG_USE_INDEX_ITERATOR_IMPLEMENTATION
|
||||
#ifdef SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION
|
||||
// ! Error in GCC4.7
|
||||
SPROUT_STATIC_CONSTEXPR auto str3 = str1 + sprout::to_string("hogehoge");
|
||||
TESTSPR_BOTH_ASSERT(str3 == "foobar1234hogehoge");
|
||||
|
|
|
@ -61,12 +61,30 @@ namespace sprout {
|
|||
public:
|
||||
value_type elems[static_size ? static_size : 1];
|
||||
public:
|
||||
// construct/copy/destroy:
|
||||
template<typename T2>
|
||||
array& operator=(array<T2, N> const& rhs) {
|
||||
std::copy(rhs.begin(), rhs.end(), begin());
|
||||
return *this;
|
||||
}
|
||||
template<typename T2>
|
||||
array& operator=(array<T2, N>&& rhs) {
|
||||
std::move(rhs.begin(), rhs.end(), begin());
|
||||
return *this;
|
||||
}
|
||||
// modifiers:
|
||||
void fill(const_reference value) {
|
||||
std::fill_n(begin(), size(), value);
|
||||
}
|
||||
SPROUT_CONSTEXPR array fill(const_reference value) const {
|
||||
return fill_impl(value, sprout::index_n<0, N>::make());
|
||||
}
|
||||
void assign(const_reference value) {
|
||||
fill(value);
|
||||
}
|
||||
SPROUT_CONSTEXPR array assign(const_reference value) const {
|
||||
return fill(value);
|
||||
}
|
||||
void swap(array& other)
|
||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::swap(std::declval<T&>(), std::declval<T&>())))
|
||||
{
|
||||
|
@ -181,26 +199,13 @@ namespace sprout {
|
|||
SPROUT_CONSTEXPR const_pointer data() const SPROUT_NOEXCEPT {
|
||||
return &elems[0];
|
||||
}
|
||||
// others:
|
||||
template<typename T2>
|
||||
array& operator=(array<T2, N> const& rhs) {
|
||||
std::copy(rhs.begin(), rhs.end(), begin());
|
||||
return *this;
|
||||
}
|
||||
template<typename T2>
|
||||
array& operator=(array<T2, N>&& rhs) {
|
||||
std::move(rhs.begin(), rhs.end(), begin());
|
||||
return *this;
|
||||
}
|
||||
pointer c_array() SPROUT_NOEXCEPT {
|
||||
return &elems[0];
|
||||
return data();
|
||||
}
|
||||
void assign(const_reference value) {
|
||||
fill(value);
|
||||
}
|
||||
SPROUT_CONSTEXPR array assign(const_reference value) const {
|
||||
return fill(value);
|
||||
SPROUT_CONSTEXPR const_pointer c_array() const SPROUT_NOEXCEPT {
|
||||
return data();
|
||||
}
|
||||
// others:
|
||||
void rangecheck(size_type i) const {
|
||||
if (i >= size()) {
|
||||
throw std::out_of_range("array<>: index out of range");
|
||||
|
|
Loading…
Reference in a new issue