Пространства имён
Варианты
Действия

Заголовочный файл стандартной библиотеки <stacktrace> (C++23)

Материал из cppreference.com
< cpp‎ | header
 
 
Заголовочные файлы стандартной библиотеки
Языковая поддержка
Концепты
<concepts> (C++20)
Диагностика
<stdexcept>
<stacktrace> (C++23)
<system_error> (C++11)

Управление памятью
<memory_resource> (C++17)  
Метапрограммирование
<type_traits> (C++11)
<ratio> (C++11)
Общие утилиты
<utility>
<tuple> (C++11)
<optional> (C++17)
<variant> (C++17)
<any> (C++17)
<expected> (C++23)
<bitset>

<charconv> (C++17)
<format> (C++20)
<bit> (C++20)

Строки
<cuchar> (C++11)

Контейнеры
<flat_set> (C++23)
<span> (C++20)
<mdspan> (C++23)

Итераторы
<iterator>
Диапазоны
<ranges> (C++20)
<generator> (C++23)
Алгоритмы
Числа
<cfenv> (C++11)
<complex>
<numbers> (C++20)

Время
<chrono> (C++11)
Локализация
<codecvt> (C++11/17*)
Ввод/вывод
<filesystem> (C++17)
<cstdio>
<cinttypes> (C++11)
<strstream> (C++98*)
Регулярные выражения
<regex> (C++11)
Поддержка конкуренции
<stop_token> (C++20)
<thread> (C++11)
<atomic> (C++11)
<stdatomic.h> (C++23)
<mutex> (C++11)
<shared_mutex> (C++14)
<condition_variable> (C++11)  
<semaphore> (C++20)
<latch> (C++20)
<barrier> (C++20)
<future> (C++11)

Совместимость с C
<cstdbool> (C++11/17/20*)  
<ccomplex> (C++11/17/20*)
<ctgmath> (C++11/17/20*)

<cstdalign> (C++11/17/20*)

<ciso646> (до C++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_stracktrace
(шаблон функции) [править]

[править] Резюме

namespace std {
  // класс stacktrace_entry
  class stacktrace_entry;
 
  // шадлонный класс basic_stacktrace
  template<class Allocator>
    class basic_stacktrace;
 
  // typedef имя basic_stacktrace
  using stacktrace = basic_stacktrace<allocator<stacktrace_entry>>;
 
  // функции, не являющиеся элементами
  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>>;
  }
 
  // поддержка хеширования
  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 = /* определено-реализацией */;
 
    // конструкторы
    constexpr stacktrace_entry() noexcept;
    constexpr stacktrace_entry(const stacktrace_entry& other) noexcept;
    constexpr stacktrace_entry& operator=(const stacktrace_entry& other) noexcept;
 
    ~stacktrace_entry();
 
    // наблюдатели
    constexpr native_handle_type native_handle() const noexcept;
    constexpr explicit operator bool() const noexcept;
 
    // запрос
    string description() const;
    string source_file() const;
    uint_least32_t source_line() const;
 
    // сравнения
    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 = /* определено-реализацией */;
    using iterator = const_iterator;
    using reverse_iterator = std::reverse_iterator<iterator>;
    using const_reverse_iterator = std::reverse_iterator<const_iterator>;
    using difference_type = /* определено-реализацией */;
    using size_type = /* определено-реализацией */;
    using allocator_type = Allocator;
 
    // создание и присваивание
    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();
 
    // наблюдатели
    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;
 
    [[nodiscard]] 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;
 
    // сравнения
    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;
 
    // модификаторы
    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_;         // только для пояснения
  };
}