Skip to content

`className(expr)` should give the dynamic type

Currently, className(expr) is just a pre-C++11 type-deduction helper forwarding to className<Type>(). It can't even deal with rvalue arguments.

Getting a demangled dynamic type from className(expr) would be useful e.g. here: dune-istl!284 (comment 55160)

Changing className(expr) to return the dynamic would mean:

  • if expr is an lvalue and the static type of expr "is virtual":

    report dynamic type rather than static type

  • if expr is an lvalue and "not virtual":

    no change

  • otherwise expr is an rvalue:

    (optional) report dynamic type rather than failing to compile

Additionally, exposing the demangling facility would be helpful.

Thoughts?