C++ 自动计算函数签名

August 11, 2021 最近研究 emscripten 的 binding 实现,发现个自动计算函数签名的实现,挺有意思,直接看代码: https://github.com/emscripten-core/emscripten/blob/f099e309d6ab1b2ec6e1967a72d5e4e90ea19abf/system/include/emscripten/bind.h#L397 //////////////////////////////////////////////////////////////////////////////// // SignatureCode, SignatureString //////////////////////////////////////////////////////////////////////////////// namespace internal { template<typename T> struct SignatureCode {}; template<> struct SignatureCode<int> { static constexpr char get() { return 'i'; } }; template<> struct SignatureCode<void> { static constexpr char get() { return 'v'; } }; template<> struct SignatureCode<float> { static constexpr charContinue reading “C++ 自动计算函数签名”