When working with templates in C++ any errors cause the compiler to emit a lot of output. In most cases when I am working on something most of that information is noise and I have to scroll around looking for the info I am interested in, for example:
std::string
is written as std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >
, or expanded typedefs / alias declarations. I would prefer to have them unexpanded for easier reading.Is it possible in either g++ or clang to reduce any of this for shorter/simpler output?
Obviously the information can be important, but then I would prefer to compile again with more verbosity and keep it short and simple by default.
Unfortunately there's no way to deal with this currently. C++20 solves this problem by introducing concepts, where templates can have abstract definitions that are restricted with everything except for their binary layout. Violating these definitions will provide simple errors.
Currently, I dig into these lines and I got used to it. I'm currently dealing with a program with 5 template parameters at places. It's all about getting used to it and training your eyes to parse the content.
However, if you're really stuck, one solution I may suggest is that you copy all the relevant error output to some editor, and do a find-and-replace to simplify individual expressions, making them smaller and smaller with every replace until it becomes readable for you. Good skills in regex may help as well. In Notepad++ (or Notepadqq on linux), you can find regular expressions and use capture groups in the replacement with \1
for first capture group, \2
for second, etc.
So, bottom line: Until C++20, there's no clean solution for this except what you invent yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With