From cppreference.com
staticbasic_stacktracecurrent(constallocator_type&alloc=allocator_type())noexcept; (1) (since C++23)staticbasic_stacktracecurrent(size_typeskip,constallocator_type&alloc=allocator_type())noexcept; (2) (since C++23)staticbasic_stacktracecurrent(size_typeskip,size_typemax_depth,constallocator_type&alloc=allocator_type())noexcept; (3) (since C++23)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 a basic_stacktrace consisting of s[0], s[1], ..., s[n-1].
2) Attempts to create a basic_stacktrace consisting of s[m], s[m+1], ..., s[n-1], where m is min(skip, n).
3) Attempts to create a basic_stacktrace consisting of s[m], s[m+1], ..., s[o-1], where m is min(skip, n) and o is min(skip + max_depth, n).
If ship<skip+max_depth is false (i.e. the mathematical result of skip+max_depth overflows), the behavior is undefined.
(until C++26)If ship<skip+max_depth is false (i.e. the mathematical result of skip+max_depth overflows):
If the implementation is
, a
occurs.
If the implementation is not hardened, the behavior is undefined.
(since C++26)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 constructed basic_stacktraceskip - the number of stacktrace entries to skip max_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
See also
creates a new basic_stacktrace
(public member function)
[static]
constructs a new source_location corresponding to the location of the call site
(public static member function of std::source_location)