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

4189. cache_latest_view should be freestanding

Section: 17.3.2 [version.syn], 25.2 [ranges.syn] Status: WP Submitter: Hewill Kang Opened: 2024-12-23 Last modified: 2025-02-16

Priority: Not Prioritized

View all other issues in [version.syn].

View all issues with WP status.

Discussion:

cache_latest_view can be freestanding, but this never comes up in the discussion, which seems to be an oversight.

Previous resolution [SUPERSEDED]:

This wording is relative to N5001.

  1. Modify 17.3.2 [version.syn] as indicated:

    #define __cpp_lib_ranges_cache_latest 202411L // freestanding, also in <ranges>
    
  2. Modify 25.2 [ranges.syn] as indicated:

    #include <compare>              // see 17.11.1 [compare.syn]
    #include <initializer_list>     // see 17.10.2 [initializer.list.syn]
    #include <iterator>             // see 24.2 [iterator.synopsis]
    
    namespace std::ranges {
      […]
      // 25.7.34 [range.cache.latest], cache latest view
      template<input_range V>
        requires view<V>
      class cache_latest_view;                                                                // freestanding
      
      namespace views { inline constexpr unspecified cache_latest = unspecified; }            // freestanding
      […]
    }
    

[2025-01-04; Tim Song suggests alternative wording]

While we are here, we can use the new convention from P2407 to dramatically simplify <ranges>. Most future additions to this header should have no problem being freestanding, so that is the right default.

[2025-02-07; Reflector poll]

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

[Hagenberg 2025-02-16; Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N5001.

  1. Modify 17.3.2 [version.syn] as indicated:

    #define __cpp_lib_ranges_cache_latest 202411L // freestanding, also in <ranges>
    
  2. Delete all "// freestanding" comments in 25.2 [ranges.syn], header <ranges> synopsis, and then modify as indicated:

    // mostly freestanding
    #include <compare>              // see 17.11.1 [compare.syn]
    #include <initializer_list>     // see 17.10.2 [initializer.list.syn]
    #include <iterator>             // see 24.2 [iterator.synopsis]
    
    […]
    namespace std::ranges {
      // 25.5.6 [range.elementsof], class template elements_of
      template<range R, class Allocator = allocator<byte>>
        struct elements_of;  // hosted
      […]
    
      // 25.6.6 [range.istream], istream view
      template<movable Val, class CharT, class Traits = char_traits<CharT>>
        requires see below
      class basic_istream_view;  // hosted
      template<class Val>
        using istream_view = basic_istream_view<Val, char>;   // hosted
      template<class Val>
        using wistream_view = basic_istream_view<Val, wchar_t>;   // hosted
    
      namespace views {
        template<class T> constexpr unspecified istream = unspecified; // hosted
      }
      […]
    }
    […]