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

4286. Some more feature-test macros for fully freestanding features are not marked freestanding

Section: 17.3.2 [version.syn], 20.2.2 [memory.syn] Status: New Submitter: Yihe Li Opened: 2025-06-17 Last modified: 2025-07-05

Priority: Not Prioritized

View other active issues in [version.syn].

View all other issues in [version.syn].

View all issues with New status.

Discussion:

P1642R11 (accepted in C++23) plus LWG 4189(i) (accepted in Hagenberg) added nearly the entire <ranges> header to freestanding. However, the only feature-test macro being added to freestanding is __cpp_lib_ranges_cache_latest, which seems weird, since views::enumerate is also added to freestanding following the blanket comment strategy, but its feature-test macro remains not in freestanding. In retrospective, since all range algorithms are in freestanding via P2976, all __cpp_lib_ranges_* FTMs (except __cpp_lib_ranges_generate_random since ranges::generate_random is not in freestanding) should probably be marked as freestanding.

Furthermore, LWG 4126(i) left out some other FTMs for fully freestanding features. They are also added in the following wording.

A note about is_sufficiently_aligned: P2897R7 does indicate in 5.7.6.1 that the function should be freestanding, but somehow the wording didn't say so. The following wording includes the function and its FTM anyway since hopefully this is just an omission when wording the paper.

Proposed resolution:

This wording is relative to N5008.

  1. Modify 17.3.2 [version.syn], header <version> synopsis, as indicated:

    […]
    #define __cpp_lib_aligned_accessor             202411L // freestanding, also in <mdspan>
    […]                                     
    #define __cpp_lib_array_constexpr              201811L // freestanding, also in <iterator>, <array>
    […]                                     
    #define __cpp_lib_clamp                        201603L // freestanding, also in <algorithm>
    […]                                     
    #define __cpp_lib_constexpr_numeric            201911L // freestanding, also in <numeric>
    […]                                     
    #define __cpp_lib_function_ref                 202306L // freestanding, also in <functional>
    #define __cpp_lib_gcd_lcm                      201606L // freestanding, also in <numeric>
    […]
    #define __cpp_lib_integer_comparison_functions 202002L // freestanding, also in <utility>
    […]
    #define __cpp_lib_is_sufficiently_aligned      202411L // freestanding, also in <memory>
    […]
    #define __cpp_lib_ranges_contains              202207L // freestanding, also in <algorithm>
    #define __cpp_lib_ranges_enumerate             202302L // freestanding, also in <ranges>
    #define __cpp_lib_ranges_find_last             202207L // freestanding, also in <algorithm>
    #define __cpp_lib_ranges_fold                  202207L // freestanding, also in <algorithm>
    […]
    #define __cpp_lib_ranges_iota                  202202L // freestanding, also in <numeric>
    […]
    #define __cpp_lib_ranges_starts_ends_with      202106L // freestanding, also in <algorithm>
    […]
    #define __cpp_lib_robust_nonmodifying_seq_ops  201304L // freestanding, also in <algorithm>
    #define __cpp_lib_sample                       201603L // freestanding, also in <algorithm>
    #define __cpp_lib_saturation_arithmetic        202311L // freestanding, also in <numeric>
    […]
    
  2. Modify 20.2.2 [memory.syn], header <memory> synopsis, as indicated:

    […]
    template<size_t Alignment, class T>
      bool is_sufficiently_aligned(T* ptr);      // freestanding
    […]