inspect C++ template instantiation

后端 未结 1 414
醉酒成梦
醉酒成梦 2021-01-02 22:17

Is there some utility which would allow me to inspect template instantiation? my compiler is g++ or Intel.

Specific points I would like:

  • Step by step i
相关标签:
1条回答
  • 2021-01-02 22:33

    With templates we simply don't have clean output facilities and there are no compilers i know of that allow you to directly view template instantiations. The closest i found regarding metaprogram debugging was a paper on Templight.

    For now the best utilities seem to be:

    • static asserts & concept checks (clearly assert your assumptions)
    • the mentioned instantiation backtraces (e.g. by using static asserts)
    • letting instantiations generate warnings (boost::mpl::print might do it)
    • a tracer, a custom class that gets passed as a template argument and is used to emit runtime output (introduced by C++ Templates - The Complete Guide)
    0 讨论(0)
提交回复
热议问题