| 391 | |
| 392 | template <bool R = Resizable, enable_if_t<R, int> = 0> |
| 393 | bool convert_elements(handle seq, bool convert) { |
| 394 | auto l = reinterpret_borrow<sequence>(seq); |
| 395 | value.reset(new ArrayType{}); |
| 396 | // Using `resize` to preserve the behavior exactly as it was before PR #5305 |
| 397 | // For the `resize` to work, `Value` must be default constructible. |
| 398 | // For `std::valarray`, this is a requirement: |
| 399 | // https://en.cppreference.com/w/cpp/named_req/NumericType |
| 400 | value->resize(l.size()); |
| 401 | size_t ctr = 0; |
| 402 | for (const auto &it : l) { |
| 403 | value_conv conv; |
| 404 | if (!conv.load(it, convert)) { |
| 405 | return false; |
| 406 | } |
| 407 | (*value)[ctr++] = cast_op<Value &&>(std::move(conv)); |
| 408 | } |
| 409 | return true; |
| 410 | } |
| 411 | |
| 412 | template <bool R = Resizable, enable_if_t<!R, int> = 0> |
| 413 | bool convert_elements(handle seq, bool convert) { |