From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTPS id C940A3858437 for ; Thu, 21 Oct 2021 14:37:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C940A3858437 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-527-eW28uLOTP1KkvZGIsubTzw-1; Thu, 21 Oct 2021 10:37:19 -0400 X-MC-Unique: eW28uLOTP1KkvZGIsubTzw-1 Received: by mail-qt1-f197.google.com with SMTP id x28-20020ac8701c000000b0029f4b940566so570518qtm.19 for ; Thu, 21 Oct 2021 07:37:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=8j4Um8R6gbygmsOu5/D/4zUZ6Bcd3dcfpX2BodEZuFc=; b=ZHNDbM14Q0b1vtG9tFi7pbYM6NbEMIWW/Ry8/GGlvZQTem1BmAOj2hFBj+JB0cFWrX 8bc83OgyO/E57cSjtihXkWYGCzYP71redMObKwOdBpnVZa/6q0VgaSP2uZAwnkxd2ei6 hrxivzjJm4RW1tM49W13PR7O1QUpABiMhPXbuih9aPMjCu5pOcFhAyYZvqFHYNar2Pjz fWIw1yGPns97CRJeUsYPOMjzuI59dHER1kHz1U+t2lvCyivru3RznTSkR7HZ2KBjCjXD ZG9teTV2PCpX1mdk7odKQbYTGERl/61SS/HC6QZF76PoQq+IouCD5SbFvYfH4RUHxin1 HR2A== X-Gm-Message-State: AOAM532bqpQ72qGO/vjKhjWrdC3P38YHU+0JYd776fnQ+wZZe+C+9hHH 20TFAUQEl4HGpnnnhtVUI9wQjHXcCWebjnbYZ2GHqxaNyRpJCa4si1nSp4R2+yRXWmKEx/06s7h 4/Dnq0iW0oZQJ008= X-Received: by 2002:a37:b141:: with SMTP id a62mr4641499qkf.518.1634827038746; Thu, 21 Oct 2021 07:37:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR17jjhDMjIL/qNTli5D8FGluyl18uWJZJCelqy/GPkTDbx3zZgWV2i77Eaokskcvu+p/CNQ== X-Received: by 2002:a37:b141:: with SMTP id a62mr4641472qkf.518.1634827038435; Thu, 21 Oct 2021 07:37:18 -0700 (PDT) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id g1sm2527513qkd.89.2021.10.21.07.37.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 07:37:18 -0700 (PDT) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: libstdc++@gcc.gnu.org, Patrick Palka Subject: [PATCH] libstdc++: missing constexpr for __[nm]iter_base [PR102358] Date: Thu, 21 Oct 2021 10:36:55 -0400 Message-Id: <20211021143655.2107584-1-ppalka@redhat.com> X-Mailer: git-send-email 2.33.1.711.g9d530dc002 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-15.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Oct 2021 14:37:26 -0000 Tested on x86_64-pc-linux-gnu, does this look ok for trunk/11/10? PR libstdc++/102358 libstdc++-v3/ChangeLog: * include/bits/stl_iterator.h (__niter_base): Make constexpr for C++20. (__miter_base): Likewise. * testsuite/25_algorithms/move/constexpr.cc: New test. --- libstdc++-v3/include/bits/stl_iterator.h | 2 ++ .../testsuite/25_algorithms/move/constexpr.cc | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 libstdc++-v3/testsuite/25_algorithms/move/constexpr.cc diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index 8afd6756613..fbd91956ced 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -2470,6 +2470,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @} group iterators template + _GLIBCXX20_CONSTEXPR auto __niter_base(move_iterator<_Iterator> __it) -> decltype(make_move_iterator(__niter_base(__it.base()))) @@ -2483,6 +2484,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; template + _GLIBCXX20_CONSTEXPR auto __miter_base(move_iterator<_Iterator> __it) -> decltype(__miter_base(__it.base())) diff --git a/libstdc++-v3/testsuite/25_algorithms/move/constexpr.cc b/libstdc++-v3/testsuite/25_algorithms/move/constexpr.cc new file mode 100644 index 00000000000..773c55cfb50 --- /dev/null +++ b/libstdc++-v3/testsuite/25_algorithms/move/constexpr.cc @@ -0,0 +1,19 @@ +// { dg-options "-std=gnu++20" } +// { dg-do compile { target c++20 } } + +#include +#include + +constexpr bool +test01() +{ + // PR libstdc++/102358 + int x[2] = {1,2}, y[2]; + std::span in(x), out(y); + std::move(std::move_iterator(in.begin()), std::move_iterator(in.end()), + out.begin()); + return std::equal(std::move_iterator(in.begin()), std::move_iterator(in.end()), + std::move_iterator(out.begin())); +} + +static_assert(test01()); -- 2.33.1.711.g9d530dc002