Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofWP status.

4035.single_view should provideempty

Section: 25.6.3.2[range.single.view]Status:WPSubmitter: Hewill KangOpened: 2023-12-31Last modified: 2024-04-02

Priority:Not Prioritized

View all otherissues in [range.single.view].

View all issues withWP status.

Discussion:

Althoughsingle_view::empty can be synthesized throughview_interface,it seems more worthwhile to provide a staticempty for it which eliminates the need to pass in an object parameter, guaranteesnoexcept-ness, and is consistent with the design ofempty_view (demo):

#include <ranges>auto empty = std::views::empty<int>;static_assert(noexcept(empty.empty()));static_assert(noexcept(empty.size()));auto single = std::views::single(0);static_assert(noexcept(single.empty())); //firestatic_assert(noexcept(single.size()));

[2024-03-12; Reflector poll]

Set status to Tentatively Ready after six votes in favour during reflector poll.

[Tokyo 2024-03-23; Status changed: Voting → WP.]

Proposed resolution:

This wording is relative toN4971.

  1. Modify 25.6.3.2[range.single.view] as indicated:

    namespace std::ranges {  template<move_constructible T>    requires is_object_v<T>  class single_view : public view_interface<single_view<T>> {    […]  public:    […]    constexpr T* begin() noexcept;    constexpr const T* begin() const noexcept;    constexpr T* end() noexcept;    constexpr const T* end() const noexcept;static constexpr bool empty() noexcept;    static constexpr size_t size() noexcept;    constexpr T* data() noexcept;    constexpr const T* data() const noexcept;  };  […]}
    […]
    constexpr T* end() noexcept;constexpr const T* end() const noexcept;

    -5-Effects: Equivalent to:return data() + 1;

    static constexpr bool empty() noexcept;

    -?-Effects: Equivalent to:return false;


[8]ページ先頭

©2009-2026 Movatter.jp