Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::basic_stacktrace<Allocator>::begin,std::basic_stacktrace<Allocator>::cbegin

      From cppreference.com
      <cpp‎ |utility‎ |basic stacktrace
       
       
      Diagnostics library
       
       
      const_iterator begin()  constnoexcept;
      (1)(since C++23)
      const_iterator cbegin()constnoexcept;
      (2)(since C++23)

      Returns an iterator to the first entry of thebasic_stacktrace.

      If thebasic_stacktrace is empty, the returned iterator is equal toend().

      range-begin-end.svg

      Contents

      [edit]Parameters

      (none)

      [edit]Return value

      Iterator to the first entry.

      [edit]Complexity

      Constant.

      [edit]Example

      Run this code
      #include <algorithm>#include <iostream>#include <stacktrace> int main(){auto trace= std::stacktrace::current();auto empty_trace=std::stacktrace{}; // Print stacktrace.std::for_each(trace.begin(), trace.end(),[](constauto& f){std::cout<< f<<'\n';}); if(empty_trace.begin()== empty_trace.end())std::cout<<"stacktrace 'empty_trace' is indeed empty.\n";}

      Possible output:

      0x0000000000402BA8 in ./prog.exe__libc_start_main in /lib/x86_64-linux-gnu/libc.so.60x0000000000402A29 in ./prog.exestacktrace 'empty_trace' is indeed empty.

      [edit]See also

      returns an iterator to the end
      (public member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/utility/basic_stacktrace/begin&oldid=129027"

      [8]ページ先頭

      ©2009-2025 Movatter.jp