c++ - Is there a type trait to count the total number of constructors? -
is possible deduce number of constructors type has during compile time?
#include <iostream> #include <type_traits> struct a{ int m_i; float m_f //constructor 1 a(int i): m_i(i) {} //constructor 2 a(float f): m_f(f) {} }; int main() { //prints 2 std::cout << number_of_constructors<a>::value << '\n'; }
i hoping avoid macro involvement constructors, perhaps way.
is possible deduce number of constructors type has during compile time?
in c++11/14? no, far can tell.
why? because c++ don't have support reflections, there study group sg7: reflection work on proposal add reflection c++.
Comments
Post a Comment