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
|
// data
|
||||||
TESTSPR_BOTH_ASSERT(carr[0] == *arr1.data());
|
TESTSPR_BOTH_ASSERT(carr[0] == *arr1.data());
|
||||||
TESTSPR_BOTH_ASSERT(carr[0] == *arr2.data());
|
TESTSPR_BOTH_ASSERT(carr[0] == *arr2.data());
|
||||||
|
{
|
||||||
|
auto arr = arr1;
|
||||||
|
TESTSPR_ASSERT(carr[0] == *arr.data());
|
||||||
|
}
|
||||||
|
|
||||||
// c_array
|
// c_array
|
||||||
|
TESTSPR_BOTH_ASSERT(carr[0] == *arr1.c_array());
|
||||||
|
TESTSPR_BOTH_ASSERT(carr[0] == *arr2.c_array());
|
||||||
{
|
{
|
||||||
auto arr = arr1;
|
auto arr = arr1;
|
||||||
TESTSPR_ASSERT(carr[0] == *arr.c_array());
|
TESTSPR_ASSERT(carr[0] == *arr.c_array());
|
||||||
|
|
|
@ -299,7 +299,7 @@ namespace testspr {
|
||||||
|
|
||||||
// operator+
|
// operator+
|
||||||
{
|
{
|
||||||
#ifdef SPROUT_CONFIG_USE_INDEX_ITERATOR_IMPLEMENTATION
|
#ifdef SPROUT_USE_INDEX_ITERATOR_IMPLEMENTATION
|
||||||
// ! Error in GCC4.7
|
// ! Error in GCC4.7
|
||||||
SPROUT_STATIC_CONSTEXPR auto str3 = str1 + sprout::to_string("hogehoge");
|
SPROUT_STATIC_CONSTEXPR auto str3 = str1 + sprout::to_string("hogehoge");
|
||||||
TESTSPR_BOTH_ASSERT(str3 == "foobar1234hogehoge");
|
TESTSPR_BOTH_ASSERT(str3 == "foobar1234hogehoge");
|
||||||
|
|
|
@ -61,12 +61,30 @@ namespace sprout {
|
||||||
public:
|
public:
|
||||||
value_type elems[static_size ? static_size : 1];
|
value_type elems[static_size ? static_size : 1];
|
||||||
public:
|
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) {
|
void fill(const_reference value) {
|
||||||
std::fill_n(begin(), size(), value);
|
std::fill_n(begin(), size(), value);
|
||||||
}
|
}
|
||||||
SPROUT_CONSTEXPR array fill(const_reference value) const {
|
SPROUT_CONSTEXPR array fill(const_reference value) const {
|
||||||
return fill_impl(value, sprout::index_n<0, N>::make());
|
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)
|
void swap(array& other)
|
||||||
SPROUT_NOEXCEPT_EXPR(SPROUT_NOEXCEPT_EXPR(std::swap(std::declval<T&>(), std::declval<T&>())))
|
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 {
|
SPROUT_CONSTEXPR const_pointer data() const SPROUT_NOEXCEPT {
|
||||||
return &elems[0];
|
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 {
|
pointer c_array() SPROUT_NOEXCEPT {
|
||||||
return &elems[0];
|
return data();
|
||||||
}
|
}
|
||||||
void assign(const_reference value) {
|
SPROUT_CONSTEXPR const_pointer c_array() const SPROUT_NOEXCEPT {
|
||||||
fill(value);
|
return data();
|
||||||
}
|
|
||||||
SPROUT_CONSTEXPR array assign(const_reference value) const {
|
|
||||||
return fill(value);
|
|
||||||
}
|
}
|
||||||
|
// others:
|
||||||
void rangecheck(size_type i) const {
|
void rangecheck(size_type i) const {
|
||||||
if (i >= size()) {
|
if (i >= size()) {
|
||||||
throw std::out_of_range("array<>: index out of range");
|
throw std::out_of_range("array<>: index out of range");
|
||||||
|
|
Loading…
Reference in a new issue