<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/c-26-std-is-within-lifetime-tirxth986" -->

---
title: C++26: std::is_within_lifetime | daily.dev
description: C++26 introduces `std::is_within_lifetime(const T* p)` in the `<type_traits>` header, a consteval-only function that checks whether a pointer points to an...
canonical: https://daily.dev/posts/c-26-std-is-within-lifetime-tirxth986
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: C++26: std::is_within_lifetime | daily.dev
og:description: C++26 introduces `std::is_within_lifetime(const T* p)` in the `<type_traits>` header, a consteval-only function that checks whether a pointer points to an...
og:url: https://daily.dev/posts/c-26-std-is-within-lifetime-tirxth986
og:image: https://api.daily.dev/og/posts/TIrXtH986.png
og:image:alt: C++26: std::is_within_lifetime
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# C++26: std::is_within_lifetime

**[Sandor Dargo](https://daily.dev/sources/sandordargo)** · 5 min read · 1 upvotes · 0 comments

## Summary

C++26 introduces `std::is_within_lifetime(const T* p)` in the `<type_traits>` header, a consteval-only function that checks whether a pointer points to an object currently within its lifetime during constant evaluation. Its primary use case is determining which member of a union is active at compile time. The motivation came from implementing a space-efficient `Optional<bool>` type that uses a union of `bool` and `char`, where a sentinel value works at runtime but not during constant evaluation. The function takes a pointer (not a reference) to avoid complications with temporaries, is consteval-only by design since runtime has other tracking mechanisms, and was given a general name rather than a union-specific one to allow broader future use. As of February 2026, no major compiler has implemented this feature yet.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.sandordargo.com/blog/2026/02/18/cpp26-std_is_within_lifetime>

## Similar posts on daily.dev

- [C\+\+26: std::indirect](https://daily.dev/posts/c-26-std-indirect-rwwdwxrjf) · Sandor Dargo · 0 upvotes · 0 comments
- [Accessing inactive union members through char: the aliasing rule you didn't know about](https://daily.dev/posts/accessing-inactive-union-members-through-char-the-aliasing-rule-you-didn-t-know-about-2jdaonlno) · Sandor Dargo · 0 upvotes · 0 comments
- [What reinterpret\_cast doesn't do](https://daily.dev/posts/what-reinterpret-cast-doesn-t-do-g4ungn0ba) · Andreas Fertig · 0 upvotes · 0 comments
- [Thoughts on P3858R0 restart\_lifetime<T>](https://daily.dev/posts/thoughts-on-p3858r0-restart-lifetime-t--zfiryrnba) · Arthur O'Dwyer · 0 upvotes · 0 comments
- [Const References to Temporary Objects](https://daily.dev/posts/const-references-to-temporary-objects-douypjnll) · Jacek Galowicz · 0 upvotes · 0 comments

---

Tags: [#c++](https://daily.dev/tags/c++)

[View this post on daily.dev](https://daily.dev/posts/c-26-std-is-within-lifetime-tirxth986)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"C++26: std::is_within_lifetime","url":"https://daily.dev/posts/c-26-std-is-within-lifetime-tirxth986","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/c-26-std-is-within-lifetime-tirxth986"},"datePublished":"2026-02-18T20:29:11.044Z","dateModified":"2026-02-18T20:29:31.202Z","description":"C++26 introduces `std::is_within_lifetime(const T* p)` in the `<type_traits>` header, a consteval-only function that checks whether a pointer points to an...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bc56fe31dfb8fc6b112ce220016c1fe6?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/bc56fe31dfb8fc6b112ce220016c1fe6?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Sandor Dargo","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Sandor Dargo","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/48d17993e5864d66951193405fa786bb","url":"https://daily.dev/sources/sandordargo"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/c-26-std-is-within-lifetime-tirxth986","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"c++","timeRequired":"PT5M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Sandor Dargo","item":"https://daily.dev/sources/sandordargo"},{"@type":"ListItem","position":3,"name":"C++26: std::is_within_lifetime"}]}
```

