From patchwork Thu Sep 11 11:39:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Grosheintz X-Patchwork-Id: 120069 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C8ADB3858434 for ; Thu, 11 Sep 2025 11:47:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C8ADB3858434 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=ELKBWwUT X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id DBBA1385841B; Thu, 11 Sep 2025 11:39:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DBBA1385841B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DBBA1385841B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757590775; cv=none; b=GuZzngMPI/XLCktbJrbWWDVbJHq4zasB+JHKkJdVn7UZ6rH/99RDkF/eACdVOEW1oa+hHoOLP5pyHBREl4LY7f/oJBbBh1s9DqmShwPT9XgoHNEmAQeqh+NZLk8bZJlASmeVaQRaT+XVTYGFGCvNpLxVNNVKW1DGDVmiL0NvtY8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757590775; c=relaxed/simple; bh=9gqG890vgctvuwFK91GTytBRDy1prz0Uh12xTZuOJxg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=o1Nqx8xGyl/WdrAcKBH2RbfKulEs38mhKEVtTgH0I77UTP/zWZwviCJ7rzk07Nu9TwgP+wXCZ6mID+NrkBec7dIKQHRLGV9Qlfa5rs7/MXL4mobig7A09iyODQkZbqnZy+UZd9koSJd8JsBerxY7vBlcfNCwE1nzC9ERnzl1rCg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DBBA1385841B Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-45deccb2c1eso4779365e9.1; Thu, 11 Sep 2025 04:39:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757590773; x=1758195573; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=o2TJxhw51o10kyIDQTsU7LH02DwUdDvEZe+veBVIr8I=; b=ELKBWwUT9jUdDzlW8HH/LSKw6jdGynbxImvQ7o1osI9vQosMXxTK6lNWXTM8Rnxedl 0CIWE5wROhpFaSI02CmnKH5r/rqiIiwFSLnj4HA0zbHS6isKoNs9eF9PJQJQ6giXNmJh IDi8fEj2UPXUK2KONUDojq6cRThx2zWNa2dex5IBUyx+z2/H0LvNRqQSCx+u5p2+unS2 MEfobNvLa8YXH8UnSbk2Qg7cJAHIaPpRhycr5C+sJH4/AhJhWLDPXDImbw/51796xN6e GXj7RZtnxIVOr2XxcnrFMMKXsy9x9TpmQt80GtoaHCYF6yLIkydnTMmo9S18v3+TWAd9 FM2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757590773; x=1758195573; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o2TJxhw51o10k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received: by 2002:a05:600c:6304:b0:45b:43cc:e558 with SMTP id 5b1f17b1804b1-45dddef818cmr160800245e9.35.1757590773391; Thu, 11 Sep 2025 04:39:33 -0700 (PDT) Received: from rogui.localdomain (212-51-146-223.fiber7.init7.net. [212.51.146.223]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45e037b922csm21272855e9.15.2025.09.11.04.39.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Sep 2025 04:39:32 -0700 (PDT) From: Luc Grosheintz To: libstdc++@gcc.gnu.org Cc: gcc-patches@gcc.gnu.org, Luc Grosheintz Subject: [PATCH v2 4/5] libstdc++: Refactor __mdspan::__static_quotient. Date: Thu, 11 Sep 2025 13:39:16 +0200 Message-ID: <20250911113917.350920-5-luc.grosheintz@gmail.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250911113917.350920-1-luc.grosheintz@gmail.com> References: <20250911113917.350920-1-luc.grosheintz@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~patchwork=sourceware.org@gcc.gnu.org For padded layouts we want to check that the product of the padded stride with the remaining extents is representable. Creating a second overload, allows passing in subspans of the static extents and retains the ergonomics for the common case of passing in all static extents. libstdc++-v3/ChangeLog: * include/std/mdspan (__static_quotient): New overload. Signed-off-by: Luc Grosheintz --- libstdc++-v3/include/std/mdspan | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/include/std/mdspan b/libstdc++-v3/include/std/mdspan index 01d3b2cb6b1..9dd0c85f5b0 100644 --- a/libstdc++-v3/include/std/mdspan +++ b/libstdc++-v3/include/std/mdspan @@ -597,13 +597,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __res; } - template + template consteval _IndexType - __static_quotient(_IndexType __nom = __gnu_cxx::__int_traits<_IndexType> - ::__max) + __static_quotient(std::span __sta_exts, + _IndexType __nom = __gnu_cxx::__int_traits<_IndexType>::__max) { - std::span __sta_exts = __static_extents<_Extents>(); for (auto __factor : __sta_exts) { if (__factor != dynamic_extent) @@ -614,6 +612,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __nom; } + template + requires __is_extents<_Extents> + consteval _IndexType + __static_quotient(_IndexType __nom = __gnu_cxx::__int_traits<_IndexType> + ::__max) + { + std::span __sta_exts = __static_extents<_Extents>(); + return __static_quotient<_IndexType>(__sta_exts, __nom); + } + template constexpr bool __is_representable_extents(const _Extents& __exts) noexcept