From patchwork Tue Feb 18 17:50:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1240242 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-519754-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=baZH4iyq; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=iFjqRl/I; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48MT0R2yGZz9sPK for ; Wed, 19 Feb 2020 04:50:31 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:in-reply-to :content-type; q=dns; s=default; b=NEYaLqkJrtbefslJaotl40nB/K+uz szsGXv1CR+VlmnpH/69dcMnFO2ijO3KW7V159ITLAp2mQ9inKPXDXwOKfTwcAOt6 MabEpgzhvqrt+RBO3qf1oIC3C++clcJarkCr4wcXEB92QYw8amQDrEufCFGkKts5 KKWeG8oKvCJ3RQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:references:mime-version:in-reply-to :content-type; s=default; bh=1UgO4oW+g8wnrOpwnGRR7Dk759U=; b=baZ H4iyqv287MNZyZCu8qhXonzP9uG7E2MzFnKQTvDsfk+z8S/Tz8yG+KFomc14BZbk 8lFJp9HoPDJJCd9t8uC4jnJ+NTJiiBUh70k5eW5jiQSIs2/QQoasmQyHB5ei373X ekg3f3lfbE0BE4B98V8t265+hpm6YFxJ5yP589YA= Received: (qmail 56952 invoked by alias); 18 Feb 2020 17:50:23 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 56924 invoked by uid 89); 18 Feb 2020 17:50:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-delivery-1.mimecast.com (HELO us-smtp-1.mimecast.com) (207.211.31.120) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Feb 2020 17:50:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582048217; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=hvHSzNvXGLaTw21nor8h5iZm2gQW0oB895XV9Cw+pdc=; b=iFjqRl/Ix8AOu6JiLDTEWCAECTi8qQun9Ns4fVYshsycPG4lANgStBCtXtK+YOco+WH4/V mTmnyUQFbt/A1CBNOJCExZC9T/4tWc3L4UhyLmMLkooNh3ELouJbkewS2mR9flAw0I/wgn lX5DLir/91jAgrMnt20OlPkFQhNBjTk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-177-Osw7_FJtN_ytMilzmnjO2w-1; Tue, 18 Feb 2020 12:50:14 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7D4F5107ACC9; Tue, 18 Feb 2020 17:50:13 +0000 (UTC) Received: from localhost (unknown [10.33.36.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D73619756; Tue, 18 Feb 2020 17:50:12 +0000 (UTC) Date: Tue, 18 Feb 2020 17:50:12 +0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed 2/4] libstdc++: Reorder declarations of std::span members Message-ID: <20200218175012.GF9441@redhat.com> References: <20200218174821.GA1652300@redhat.com> MIME-Version: 1.0 In-Reply-To: <20200218174821.GA1652300@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline I find it easier to work with this class when the declarations match the order in the C++2a working paper. There's no need to use long, descriptive template parameter names like _ContiguousIterator when the parameter is already constrained by the std::contiguous_iterator concept. This is also consistent with the naming conventions in the working paper. * include/std/span (span): Reorder members and rename template parameters to match declarations in the C++2a working paper. Tested powerpc64le-linux, committed to trunk. commit f09f32427b21127af0ec4c4a48dc9f3b0e696e59 Author: Jonathan Wakely Date: Tue Feb 18 12:33:07 2020 +0000 libstdc++: Reorder declarations of std::span members I find it easier to work with this class when the declarations match the order in the C++2a working paper. There's no need to use long, descriptive template parameter names like _ContiguousIterator when the parameter is already constrained by the std::contiguous_iterator concept. This is also consistent with the naming conventions in the working paper. * include/std/span (span): Reorder members and rename template parameters to match declarations in the C++2a working paper. diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span index b8d5e0797a2..feb1c1f46ad 100644 --- a/libstdc++-v3/include/std/span +++ b/libstdc++-v3/include/std/span @@ -140,25 +140,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION public: // member types - using value_type = remove_cv_t<_Type>; using element_type = _Type; + using value_type = remove_cv_t<_Type>; using size_type = size_t; - using reference = element_type&; - using const_reference = const element_type&; + using difference_type = ptrdiff_t; using pointer = _Type*; using const_pointer = const _Type*; - using iterator - = __gnu_cxx::__normal_iterator; - using const_iterator - = __gnu_cxx::__normal_iterator; + using reference = element_type&; + using const_reference = const element_type&; + using iterator = __gnu_cxx::__normal_iterator; + using const_iterator = __gnu_cxx::__normal_iterator; using reverse_iterator = std::reverse_iterator; using const_reverse_iterator = std::reverse_iterator; - using difference_type = ptrdiff_t; // member constants - static inline constexpr size_t extent = _Extent; + static constexpr size_t extent = _Extent; - // constructors + // constructors, copy and assignment constexpr span() noexcept @@ -166,8 +164,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _M_extent(0), _M_ptr(nullptr) { } - constexpr - span(const span&) noexcept = default; + template + requires (__is_compatible_iterator<_It>::value) + constexpr + span(_It __first, size_type __count) + noexcept + : _M_extent(__count), _M_ptr(std::to_address(__first)) + { __glibcxx_assert(_Extent == dynamic_extent || __count == _Extent); } + + template _End> + requires (__is_compatible_iterator<_It>::value) + && (!is_convertible_v<_End, size_type>) + constexpr + span(_It __first, _End __last) + noexcept(noexcept(__last - __first)) + : _M_extent(static_cast(__last - __first)), + _M_ptr(std::to_address(__first)) + { + if (_Extent != dynamic_extent) + __glibcxx_assert((__last - __first) == _Extent); + } template requires (__is_compatible_array<_Tp, _ArrayExtent>::value) @@ -203,27 +219,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : span(ranges::data(__range), ranges::size(__range)) { } - template _Sentinel> - requires (__is_compatible_iterator<_ContiguousIterator>::value) - && (!is_convertible_v<_Sentinel, size_type>) - constexpr - span(_ContiguousIterator __first, _Sentinel __last) - noexcept(noexcept(__last - __first)) - : _M_extent(static_cast(__last - __first)), - _M_ptr(std::to_address(__first)) - { - if (_Extent != dynamic_extent) - __glibcxx_assert((__last - __first) == _Extent); - } - - template - requires (__is_compatible_iterator<_ContiguousIterator>::value) - constexpr - span(_ContiguousIterator __first, size_type __count) - noexcept - : _M_extent(__count), _M_ptr(std::to_address(__first)) - { __glibcxx_assert(_Extent == dynamic_extent || __count == _Extent); } + constexpr + span(const span&) noexcept = default; template requires (_Extent == dynamic_extent || _Extent == _OExtent) @@ -233,7 +230,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : _M_extent(__s.size()), _M_ptr(__s.data()) { } - // assignment + ~span() noexcept = default; constexpr span& operator=(const span&) noexcept = default; @@ -414,8 +411,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION span(const array<_Type, _ArrayExtent>&) -> span; - template - span(_Iter, _Sentinel) + template + span(_Iter, _End) -> span>>; template