std::basic_...ce::current(3)
π«Ά std::basic_stacktrace::current(3) β straight from the C++ Standard Libary π«Ά
okay bestie, welcome to the std::basic_stacktrace::current(3) page from the C++ Standard Libary manual. this one is lowkey niche but highkey useful: it's all about grabbing a stacktrace of the current evaluation in the current thread. let's get into it β¨
β¨ NAME β¨
std::basic_stacktrace::current β std::basic_stacktrace::current
(yes, that's the whole name section, and honestly? iconic repetition π )
π Synopsis π
here's the synopsis, copied exactly because we do not mess with signatures in this house π«Ά
static basic_stacktrace current( const allocator_type& alloc =
(1) (since C++23)
allocator_type() ) noexcept;
static basic_stacktrace current( size_type skip, const
allocator_type& alloc =
(2) (since C++23)
allocator_type() ) noexcept;
static basic_stacktrace current( size_type skip, size_type
max_depth,
(3)
(since C++23)
const allocator_type& alloc =
allocator_type() ) noexcept;
Let s[i] (0 β€ i < n) denote the (i+1)-th stacktrace entry in the stacktrace of the current evaluation in the current thread of execution, where n is the count of the stacktrace entries in the stackentry.
(1)β Attempts to create abasic_stacktraceconsisting ofs[0],s[1], ...,s[n - 1].(2)β Attempts to create abasic_stacktraceconsisting ofs[m],s[m + 1], ...,s[n - 1], wheremismin(skip, n).(3)β Attempts to create abasic_stacktraceconsisting ofs[m],s[m + 1], ...,s[o - 1], wheremismin(skip, n)andoismin(skip + max_depth, n). The behavior is undefined ifskip + max_depth < skip(i.e. the mathematical result ofskip + max_depthoverflows). π«
In all cases, alloc is stored into the created basic_stacktrace and used to allocate the storage for stacktrace entries.
π Parameters π
allocβ allocator to use for all memory allocations of the constructedbasic_stacktraceskipβ the number of stacktrace entries to skipmax_depthβ the maximum depth of the stacktrace entries
π Return value π
If the allocation succeeds, the basic_stacktrace described above.
Otherwise, an empty basic_stacktrace.
π¦ Example π¦
This section is incomplete Reason: no example
not me showing up to the example section with nothing but vibes π
πΈ See also πΈ
constructorβ creates a newbasic_stacktrace(public member function)current[static]β constructs a newsource_locationcorresponding to the location of the call site (public static member function ofstd::source_location)
β Category β
* Todo no example
mwah π this page came from http://cppreference.com, version/date 2024.06.10, and the page title is std::basic_...ce::current(3). bye bestie, go build something iconic πβ¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms