[stacktrace.entry]

# 19 Diagnostics library [[diagnostics]](./#diagnostics)

## 19.6 Stacktrace [[stacktrace]](stacktrace#entry)

### 19.6.3 Class stacktrace_entry [stacktrace.entry]

#### [19.6.3.1](#overview) Overview [[stacktrace.entry.overview]](stacktrace.entry.overview)

namespace std {class [stacktrace_entry](#lib:stacktrace_entry "19.6.3.1 Overview [stacktrace.entry.overview]") {public:using native_handle_type = *implementation-defined*; // [[stacktrace.entry.cons]](#cons "19.6.3.2 Constructors"), constructorsconstexpr stacktrace_entry() noexcept; constexpr stacktrace_entry(const stacktrace_entry& other) noexcept; constexpr stacktrace_entry& operator=(const stacktrace_entry& other) noexcept; ~stacktrace_entry(); // [[stacktrace.entry.obs]](#obs "19.6.3.3 Observers"), observersconstexpr native_handle_type native_handle() const noexcept; constexpr explicit operator bool() const noexcept; // [[stacktrace.entry.query]](#query "19.6.3.4 Query"), query string description() const;
 string source_file() const;
 uint_least32_t source_line() const; // [[stacktrace.entry.cmp]](#cmp "19.6.3.5 Comparison"), comparisonfriend constexpr bool operator==(const stacktrace_entry& x, const stacktrace_entry& y) noexcept; friend constexpr strong_ordering operator<=>(const stacktrace_entry& x, const stacktrace_entry& y) noexcept; };}

[1](#overview-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1749)

An object of type stacktrace_entry is either empty,
or represents a stacktrace entry and
provides operations for querying information about it[.](#overview-1.sentence-1)

The class stacktrace_entry models[regular](concepts.object#concept:regular "18.6 Object concepts [concepts.object]") ([[concepts.object]](concepts.object "18.6 Object concepts")) and[three_way_comparable](cmp.concept#concept:three_way_comparable "17.12.4 Concept three_­way_­comparable [cmp.concept]")<strong_ordering> ([[cmp.concept]](cmp.concept "17.12.4 Concept three_­way_­comparable"))[.](#overview-1.sentence-2)

#### [19.6.3.2](#cons) Constructors [[stacktrace.entry.cons]](stacktrace.entry.cons)

[ð](#lib:stacktrace_entry,constructor)

`constexpr stacktrace_entry() noexcept;
`

[1](#cons-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1765)

*Postconditions*: *this is empty[.](#cons-1.sentence-1)

#### [19.6.3.3](#obs) Observers [[stacktrace.entry.obs]](stacktrace.entry.obs)

[ð](#lib:native_handle,stacktrace_entry)

`constexpr native_handle_type native_handle() const noexcept;
`

[1](#obs-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1778)

The semantics of this function areimplementation-defined[.](#obs-1.sentence-1)

[2](#obs-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1782)

*Remarks*: Successive invocations of the native_handle function
for an unchanged stacktrace_entry object return identical values[.](#obs-2.sentence-1)

[ð](#lib:operator_bool,stacktrace_entry)

`constexpr explicit operator bool() const noexcept;
`

[3](#obs-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1794)

*Returns*: false if and only if *this is empty[.](#obs-3.sentence-1)

#### [19.6.3.4](#query) Query [[stacktrace.entry.query]](stacktrace.entry.query)

[1](#query-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1801)

[*Note [1](#query-note-1)*:

All the stacktrace_entry query functions treat
errors other than memory allocation errors
as âno information availableâ and do not throw in that case[.](#query-1.sentence-1)

â *end note*]

[ð](#lib:description,stacktrace_entry)

`string description() const;
`

[2](#query-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1814)

*Returns*: A description of the evaluation represented by *this,
or an empty string[.](#query-2.sentence-1)

[3](#query-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1819)

*Throws*: bad_alloc if memory for
the internal data structures or the resulting string cannot be allocated[.](#query-3.sentence-1)

[ð](#lib:source_file,stacktrace_entry)

`string source_file() const;
`

[4](#query-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1831)

*Returns*: The presumed or actual name of the source file ([[cpp.predefined]](cpp.predefined "15.12 Predefined macro names"))
that lexically contains the expression or statement
whose evaluation is represented by *this, or an empty string[.](#query-4.sentence-1)

[5](#query-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1837)

*Throws*: bad_alloc if memory for
the internal data structures or the resulting string cannot be allocated[.](#query-5.sentence-1)

[ð](#lib:source_line,stacktrace_entry)

`uint_least32_t source_line() const;
`

[6](#query-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1849)

*Returns*: 0, or a 1-based line number that lexically relates to the evaluation
represented by *this[.](#query-6.sentence-1)

If source_file returns the presumed name of the source file,
returns the presumed line number;
if source_file returns the actual name of the source file,
returns the actual line number[.](#query-6.sentence-2)

[7](#query-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1858)

*Throws*: bad_alloc if memory for
the internal data structures cannot be allocated[.](#query-7.sentence-1)

#### [19.6.3.5](#cmp) Comparison [[stacktrace.entry.cmp]](stacktrace.entry.cmp)

[ð](#lib:operator==,stacktrace_entry)

`friend constexpr bool operator==(const stacktrace_entry& x, const stacktrace_entry& y) noexcept;
`

[1](#cmp-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/diagnostics.tex#L1872)

*Returns*: true if and only if x and y represent
the same stacktrace entry or both x and y are empty[.](#cmp-1.sentence-1)
