最終更新日時(UTC):
が更新

履歴 編集

function
<stacktrace>

std::basic_stacktrace::swap(C++23)

void swap(basic_stacktrace& other)
        noexcept(
          allocator_traits<Allocator>::propagate_on_container_swap::value ||
          allocator_traits<Allocator>::is_always_equal::value
        );                           // (1) C++23

概要

他のbasic_stacktraceオブジェクトとデータを入れ替える。

効果

*thisotherの内容を交換する。

#include <iostream>
#include <stacktrace>

void g() {
  std::stacktrace a = std::stacktrace::current();
  std::stacktrace b = std::stacktrace::current();
  a.swap(b);

  std::cout << a << std::endl; // bで取得したスタックトレースが出力される
}

void f() {
  g();
}

int main() {
  f();
}

出力例

 0# g() at main.cpp:6
 1# f() at main.cpp:13
 2# main at main.cpp:17

バージョン

言語

  • C++23

処理系