名稱空間
變體
操作

標準庫標頭檔案 <stacktrace> (C++23)

來自 cppreference.com
 
 
標準庫標頭檔案
演算法
<algorithm>
<numeric>
字串
<cctype>
<cstring>
<cuchar> (C++11)
<cwchar>
<cwctype>
<string_view> (C++17)
<string>
文字處理
<clocale>
<codecvt> (C++11/17/26*)
<locale>
<regex> (C++11)
<text_encoding> (C++26)   
數值
<cfenv> (C++11)
<cmath>
<complex>
<linalg> (C++26)
<numbers> (C++20)
<random> (C++11)
<simd> (C++26)
<valarray>
時間
<chrono> (C++11)
<ctime>
C 相容性
<ccomplex> (C++11/17/20*)
<ciso646> (直到 C++20)
<cstdalign> (C++11/17/20*)
<cstdbool> (C++11/17/20*)
<ctgmath> (C++11/17/20*)
 

此標頭檔案是診斷庫的一部分。

目錄

棧追蹤中一次求值的表示
(類) [編輯]
由棧追蹤條目組成的近似呼叫序列表示
(類模板) [編輯]
std::stacktrace_entry 的雜湊支援
(類模板特化) [編輯]
std::basic_stacktrace 的雜湊支援
(類模板特化) [編輯]
前向宣告
定義於標頭檔案 <functional>
(C++11)
雜湊函式物件
(類模板) [編輯]
類型別名
別名 型別
std::stacktrace std::basic_stacktrace<std::allocator<std::stacktrace_entry>>
std::pmr::stacktrace std::pmr::basic_stacktrace<
    std::pmr::polymorphic_allocator<std::stacktrace_entry>>

函式

特化 std::swap 演算法
(函式模板) [編輯]
(C++23)
返回描述 stacktrace_entry 的字串
(函式) [編輯]
(C++23)
返回描述 basic_stacktrace 的字串
(函式模板) [編輯]
執行 stacktrace_entry 的流輸出
(函式模板) [編輯]
執行 basic_stacktrace 的流輸出
(函式模板) [編輯]

[編輯] 概要

namespace std {
  // class stacktrace_entry
  class stacktrace_entry;
 
  // class template basic_stacktrace
  template<class Allocator>
    class basic_stacktrace;
 
  // basic_stacktrace typedef names
  using stacktrace = basic_stacktrace<allocator<stacktrace_entry>>;
 
  // non-member functions
  template<class Allocator>
    void swap(basic_stacktrace<Allocator>& a, basic_stacktrace<Allocator>& b)
      noexcept(noexcept(a.swap(b)));
 
  string to_string(const stacktrace_entry& f);
 
  template<class Allocator>
    string to_string(const basic_stacktrace<Allocator>& st);
 
  ostream& operator<<(ostream& os, const stacktrace_entry& f);
 
  template<class Allocator>
    ostream& operator<<(ostream& os, const basic_stacktrace<Allocator>& st);
 
  namespace pmr {
    using stacktrace = std::basic_stacktrace<polymorphic_allocator<stacktrace_entry>>;
  }
 
  // hash support
  template<class T> struct hash;
  template<> struct hash<stacktrace_entry>;
  template<class Allocator> struct hash<basic_stacktrace<Allocator>>;
}

[編輯] std::stacktrace_entry

namespace std {
  class stacktrace_entry {
  public:
    using native_handle_type = /* implementation-defined */;
 
    // constructors
    constexpr stacktrace_entry() noexcept;
    constexpr stacktrace_entry(const stacktrace_entry& other) noexcept;
    constexpr stacktrace_entry& operator=(const stacktrace_entry& other) noexcept;
 
    ~stacktrace_entry();
 
    // observers
    constexpr native_handle_type native_handle() const noexcept;
    constexpr explicit operator bool() const noexcept;
 
    // query
    string description() const;
    string source_file() const;
    uint_least32_t source_line() const;
 
    // comparison
    friend 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;
  };
}

[編輯] 類模板 std::basic_stacktrace

namespace std {
  template<class Allocator>
  class basic_stacktrace {
  public:
    using value_type = stacktrace_entry;
    using const_reference = const value_type&;
    using reference = value_type&;
    using const_iterator = /* implementation-defined */;
    using iterator = const_iterator;
    using reverse_iterator = std::reverse_iterator<iterator>;
    using const_reverse_iterator = std::reverse_iterator<const_iterator>;
    using difference_type = /* implementation-defined */;
    using size_type = /* implementation-defined */;
    using allocator_type = Allocator;
 
    // creation and assignment
    static basic_stacktrace
      current(const allocator_type& alloc = allocator_type()) noexcept;
    static basic_stacktrace
      current(size_type skip, const allocator_type& alloc = allocator_type()) noexcept;
    static basic_stacktrace
      current(size_type skip, size_type max_depth,
              const allocator_type& alloc = allocator_type()) noexcept;
 
    basic_stacktrace() noexcept(is_nothrow_default_constructible_v<allocator_type>);
    explicit basic_stacktrace(const allocator_type& alloc) noexcept;
 
    basic_stacktrace(const basic_stacktrace& other);
    basic_stacktrace(basic_stacktrace&& other) noexcept;
    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);
 
    ~basic_stacktrace();
 
    // observers
    allocator_type get_allocator() const noexcept;
 
    const_iterator begin() const noexcept;
    const_iterator end() const noexcept;
    const_reverse_iterator rbegin() const noexcept;
    const_reverse_iterator rend() const noexcept;
 
    const_iterator cbegin() const noexcept;
    const_iterator cend() const noexcept;
    const_reverse_iterator crbegin() const noexcept;
    const_reverse_iterator crend() const noexcept;
 
    bool empty() const noexcept;
    size_type size() const noexcept;
    size_type max_size() const noexcept;
 
    const_reference operator[](size_type) const;
    const_reference at(size_type) const;
 
    // comparisons
    template<class Allocator2>
    friend bool operator==(const basic_stacktrace& x,
                           const basic_stacktrace<Allocator2>& y) noexcept;
    template<class Allocator2>
    friend strong_ordering operator<=>(const basic_stacktrace& x,
                                       const basic_stacktrace<Allocator2>& y) noexcept;
 
    // modifiers
    void swap(basic_stacktrace& other)
      noexcept(allocator_traits<Allocator>::propagate_on_container_swap::value ||
        allocator_traits<Allocator>::is_always_equal::value);
 
  private:
    vector<value_type, allocator_type> frames_;         // exposition only
  };
}