20 General utilities library [utilities]

20.21 Stacktrace [stacktrace]

20.21.4 Class template basic_­stacktrace [stacktrace.basic]

20.21.4.2 Creation and assignment [stacktrace.basic.ctor]

static basic_stacktrace current(const allocator_type& alloc = allocator_type()) noexcept;
Returns: A basic_­stacktrace object with frames_­ storing the stacktrace of the current evaluation in the current thread of execution, or an empty basic_­stacktrace object if the initialization of frames_­ failed.
alloc is passed to the constructor of the frames_­ object.
[Note 1:
If the stacktrace was successfully obtained, then frames_­.front() is the stacktrace_­entry representing approximately the current evaluation, and frames_­.back() is the stacktrace_­entry representing approximately the initial function of the current thread of execution.
— end note]
static basic_stacktrace current(size_type skip, const allocator_type& alloc = allocator_type()) noexcept;
Let t be a stacktrace as-if obtained via basic_­stacktrace​::​current(alloc).
Let n be t.size().
Returns: A basic_­stacktrace object where frames_­ is direct-non-list-initialized from arguments t.begin() + min(n, skip), t.end(), and alloc, or an empty basic_­stacktrace object if the initialization of frames_­ failed.
static basic_stacktrace current(size_type skip, size_type max_depth, const allocator_type& alloc = allocator_type()) noexcept;
Let t be a stacktrace as-if obtained via basic_­stacktrace​::​current(alloc).
Let n be t.size().
Preconditions: skip <= skip + max_­depth is true.
Returns: A basic_­stacktrace object where frames_­ is direct-non-list-initialized from arguments t.begin() + min(n, skip), t.begin() + min(n, skip + max_­depth), and alloc, or an empty basic_­stacktrace object if the initialization of frames_­ failed.
basic_stacktrace() noexcept(is_nothrow_default_constructible_v<allocator_type>);
Postconditions: empty() is true.
explicit basic_stacktrace(const allocator_type& alloc) noexcept;
Effects: alloc is passed to the frames_­ constructor.
Postconditions: empty() is true.
basic_stacktrace(const basic_stacktrace& other); basic_stacktrace(const basic_stacktrace& other, const allocator_type& alloc); basic_stacktrace(basic_stacktrace&& other, const allocator_type& alloc); basic_stacktrace& operator=(const basic_stacktrace& other); basic_stacktrace& operator=(basic_stacktrace&& other) noexcept(allocator_traits<Allocator>::propagate_on_container_move_assignment::value || allocator_traits<Allocator>::is_always_equal::value);
Remarks: Implementations may strengthen the exception specification for these functions ([res.on.exception.handling]) by ensuring that empty() is true on failed allocation.