Question Details

No question body available.

Tags

c++ reflection c++26

Answers (1)

July 12, 2026 Score: 2 Rep: 123,247 Quality: Medium Completeness: 60%

Parameters of a function are not the same as parameters of the function type. std::meta::typeof is not applicable to the latter because those are types, not entities that have types.

One solution is to split funcinfoimpl in two versions, one for operator() and one for function types. In the latter, call just std::meta::displaystringof(p), and do not call either std::meta::typeof (it is invalid) or std::meta::identifierof (it is useless). You already have if constexpr that does the dispatch. Just call two different helpers in its branches.

Another possibility is to branch on std::meta::istype inside the helper, like this:

result += "param: "; result += "["; if constexpr (std::meta::istype(p)) { result += std::meta::displaystringof(p); result += " "; } else { result += std::meta::displaystringof(std::meta::typeof(p)); result += " "; result += std::meta::hasidentifier(p) ? std::meta::identifierof(p) : ""; } result += "]\n";