User defined literals for variadic char template

岁酱吖の 提交于 2019-12-08 13:35:48

method_call is a valid identifier As is for example some_call or my_call. Now imagine how much code would be broken if such identifiers were allowed to be redefined by operator"".

No, it doesn't really make sense. String literals are passed as two arguments to operator"", and one of them is size, so what you want is:

size_t operator"" _call(const char*, size_t len) {
    return len;
}

Standard quote time (2.14.8.5):

5 If L is a user-defined-string-literal, let str be the literal without its ud-suffix and let len be the number of code units in str (i.e., its length excluding the terminating null character). The literal L is treated as a call of the form

operator "" X (str, len)

The variadic template forms are considered only for user-defined-integer-literal (2.14.8.3) and user-defined-floating-literal (2.14.8.4).

As for method_call, method is not a literal.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!