Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename T, typename R, typename... Args>
- constexpr bool ckeck_method_type() {
- char const* sig = __FUNCSIG__;
- while (*sig++ != '<') {}
- char const* f_type = sig;
- int parens = 1;
- while (*sig++ != ')') {}
- sig++;
- while (parens != 0) {
- if (*sig == '(') {
- parens++;
- }
- else if (*sig == ')') {
- parens--;
- }
- sig++;
- }
- char const* t_args = sig + 1;
- while (true) {
- if (*f_type == '(') {
- if (*t_args == ',' || *t_args == '>') {
- break;
- }
- return false;
- }
- if (*t_args == ',' || *t_args == '>') {
- if (*f_type == '(') {
- break;
- }
- return false;
- }
- if (*t_args != *f_type) {
- return false;
- }
- t_args++;
- f_type++;
- }
- while (*f_type++ != ')') {}
- f_type++;
- if (f_type[0] == 'v' && f_type[1] == 'o' && f_type[2] == 'i' && f_type[3] == 'd' && f_type[4] == ')') {
- if (t_args[0] == ',' && t_args[1] == '>') {
- return true;
- }
- return false;
- }
- t_args++;
- int deep = 1;
- while (true) {
- if (f_type[0] == 's' && f_type[1] == 't' && f_type[2] == 'r' && f_type[3] == 'u' && f_type[4] == 'c' && f_type[5] == 't' && f_type[6] == ' ') {
- if (t_args[0] == 's' && t_args[1] == 't' && t_args[2] == 'r' && t_args[3] == 'u' && t_args[4] == 'c' && t_args[5] == 't') {
- f_type += 7;
- // msvc bug
- if (t_args[6] == ' ') {
- t_args += 7;
- }
- else {
- t_args += 6;
- }
- }
- else {
- return false;
- }
- }
- if (f_type[0] == 'c' && f_type[1] == 'l' && f_type[2] == 'a' && f_type[3] == 's' && f_type[4] == 's' && f_type[5] == ' ') {
- if (t_args[0] == 'c' && t_args[1] == 'l' && t_args[2] == 'a' && t_args[3] == 's' && t_args[4] == 's') {
- f_type += 6;
- // msvc bug
- if (t_args[5] == ' ') {
- t_args += 6;
- }
- else {
- t_args += 5;
- }
- }
- else {
- return false;
- }
- }
- if (*f_type == '(') {
- deep++;
- }
- else if (*f_type == ')') {
- deep--;
- if (deep == 0) {
- if (*t_args == '>') {
- return true;
- }
- return false;
- }
- }
- if (*t_args != *f_type) {
- if (f_type[0] == ' ' && ((f_type[1] == '&' && t_args[0] == '&') || (f_type[1] == '(' && t_args[0] == '('))) {
- deep += f_type[1] == '(';
- f_type++;
- }
- else {
- return false;
- }
- }
- t_args++;
- f_type++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment