A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.github.io/LWG/issue4138 below:

Issue 4138: is_within_lifetime should mandate is_object

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.

4138. is_within_lifetime should mandate is_object

Section: 21.3.12 [meta.const.eval] Status: New Submitter: Corentin Opened: 2024-08-09 Last modified: 2024-08-11

Priority: Not Prioritized

View all issues with New status.

Discussion:

int f();
std::is_within_lifetime<int()>(f);

This is currently well-formed, and only fails when evaluated because is_within_lifetime is not constrained. However talking of lifetime of a non-object does not make sense, and the lack of constraint makes the implementation and use of that function and underlying built-in more convoluted than necessary.

Proposed resolution:

This wording is relative to N4988.

  1. Modify 21.3.3 [meta.type.synop], header <type_traits> synopsis, as indicated:

    […]
    // 21.3.12 [meta.const.eval], constant evaluation context
    constexpr bool is_constant_evaluated() noexcept;
    template<class T>
    consteval bool is_within_lifetime(const Tauto*) noexcept;
    
  2. Modify 21.3.12 [meta.const.eval] as indicated:

    template<class T>
    consteval bool is_within_lifetime(const Tauto* p) noexcept;
    

    -?- Mandates: is_object_v<T> is true.

    -3- Returns: true if p is a pointer to an object that is within its lifetime (6.8.4 [basic.life]); otherwise, false. -4- Remarks: During the evaluation of an expression E as a core constant expression, a call to this function is ill-formed unless p points to an object that is usable in constant expressions or whose complete object's lifetime began within E.

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4