• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright Antony Polukhin, 2016-2020.
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See
4 // accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6 
7 
8 //[getting_started_user_config
9 #ifndef USER_CONFIG_HPP
10 #define USER_CONFIG_HPP
11 
12 #include <boost/stacktrace/stacktrace_fwd.hpp>
13 
14 #include <iosfwd>
15 
16 namespace boost { namespace stacktrace {
17 
18 template <class CharT, class TraitsT, class Allocator>
19 std::basic_ostream<CharT, TraitsT>& do_stream_st(std::basic_ostream<CharT, TraitsT>& os, const basic_stacktrace<Allocator>& bt);
20 
21 template <class CharT, class TraitsT>
operator <<(std::basic_ostream<CharT,TraitsT> & os,const stacktrace & bt)22 std::basic_ostream<CharT, TraitsT>& operator<<(std::basic_ostream<CharT, TraitsT>& os, const stacktrace& bt) {
23     return do_stream_st(os, bt);
24 }
25 
26 }}  // namespace boost::stacktrace
27 #endif // USER_CONFIG_HPP
28 //]
29 
30 #ifndef USER_CONFIG2_HPP
31 #define USER_CONFIG2_HPP
32 
33 #include <ios> // std::streamsize
34 
35 //[getting_started_user_config_impl
36 namespace boost { namespace stacktrace {
37 
38 template <class CharT, class TraitsT, class Allocator>
do_stream_st(std::basic_ostream<CharT,TraitsT> & os,const basic_stacktrace<Allocator> & bt)39 std::basic_ostream<CharT, TraitsT>& do_stream_st(std::basic_ostream<CharT, TraitsT>& os, const basic_stacktrace<Allocator>& bt) {
40     const std::streamsize w = os.width();
41     const std::size_t frames = bt.size();
42     for (std::size_t i = 0; i < frames; ++i) {
43         os.width(2);
44         os << i;
45         os.width(w);
46         os << "# ";
47         os << bt[i].name();
48         os << '\n';
49     }
50 
51     return os;
52 }
53 
54 }}  // namespace boost::stacktrace
55 //]
56 
57 #endif // USER_CONFIG2_HPP
58 
59