$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] GDB-like debugger for template metaprograms
From: Larry Evans (cppljevans_at_[hidden])
Date: 2014-11-29 17:57:02
On 11/29/2014 04:06 PM, Mathias Gaunard wrote:
> On 29/11/2014 22:15, Abel Sinkovics wrote:
>> Hi Mathias,
>>
>> Thank you for checking it.
>>
>> On 2014-11-29 18:56, Mathias Gaunard wrote:
>>>  - pretty printing complex types so that you can actually read them
>>>    I don't think the formatter thing is a solution.
>>>    Consider an arbitrarily deep expression template tree, for example.
>> We have some ideas on how to improve pretty printing of types and
>> displaying complex template instances based on our own experience.
>>
>> How would you change/improve pretty printing in a way you find useful?
>> How would you display for example a deep expression template tree?
> 
> It can be hard to match '<' and '>' together for long symbol names
> involving instantiations of templates where the parameters are
> themselves template instantiations.
> 
> I think it would be great to have an option to automatically indent the
> type when printing so that it's easier to interpret.
> 
> Instead of
> a<b,c<d>,e<f<g,h>>,i>, you could print it as
> 
> a<
>   b,
>   c<d>,
>   e<
>     f<g, h>
>   >,
>   i
>>
Or, keep *all* the delimiters(< , and >)
lined up, as in the following
( where the delimiters are lined up only
for the expr_prefx template):
expr_prefx
< op_ator< []>
, expr_prefx
  < op_symb<lit,lit1>
  >
, expr_prefx
  < op_symb<act,action1>
  >
>
This output was produced by:
      template
      < typename Operator
      , typename... Operands
      >
        friend
      std::ostream&
    operator<<
      ( std::ostream& os
      , expr_prefx
        < Operator
        , Operands...
        >
      )
      {
          os
            <<"expr_prefx\n< "
            <<indent_buf_in<<Operator{};
          using swallow = int[]; // guaranties left to right order
          (void)swallow
          { 0
          , ( os
                <<"\n"
                <<indent_buf_out
                <<", "
                <<indent_buf_in<<Operands{}
            , 0
            )...
          };
          os<<indent_buf_out<<"\n>";
          return os;
      }
the indent_buf_in is an io manipulator that uses boost::iostreams
and an iostreams indent filter, which I can provide.
HTH.
-regards,
Larry