//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // REQUIRES: has-unix-headers // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20 // UNSUPPORTED: !libcpp-has-hardened-mode && !libcpp-has-debug-mode // XFAIL: availability-verbose_abort-missing // // template // constexpr explicit(!is_convertible_v) // mapping(const mapping&) noexcept; // Constraints: is_constructible_v is true. // // Preconditions: other.required_span_size() is representable as a value of type index_type. #include #include #include "check_assertion.h" int main(int, char**) { constexpr size_t D = std::dynamic_extent; std::extents arg_exts{100, 5}; std::layout_left::mapping> arg(arg_exts); // working case { [[maybe_unused]] std::layout_left::mapping> m(arg); // should work } // mismatch of static extent { TEST_LIBCPP_ASSERT_FAILURE(([=] { std::layout_left::mapping> m(arg); }()), "extents construction: mismatch of provided arguments with static extents."); } // non-representability of extents itself { TEST_LIBCPP_ASSERT_FAILURE(([=] { std::layout_left::mapping> m( std::layout_left::mapping>(std::extents(500))); }()), "extents ctor: arguments must be representable as index_type and nonnegative"); } // required_span_size not representable, while individual extents are { // check extents would be constructible [[maybe_unused]] std::extents e(arg_exts); // but the product is not, so we can't use it for layout_left TEST_LIBCPP_ASSERT_FAILURE( ([=] { std::layout_left::template mapping> m(arg); }()), "layout_left::mapping converting ctor: other.required_span_size() must be representable as index_type."); } return 0; }