Custom literals for char variation pattern

Recently, "user literals" have been implemented in gcc-trunk sources. Please tell me, do I understand correctly that I cannot define "user literals" for the variational char template?

template<char... chars>
int operator"" _call() { return sizeof...(chars); }
...
std::cout << "method"_call;

Up.

I do not understand why this expression is allowed:

template<char... chars>
int operator"" _call() { return sizeof...(chars); }
...
std::cout << 12345566_call;

and this ban:

template<char... chars>
int operator"" _call() { return sizeof...(chars); }
...
std::cout << method_call;

?

What is the point?

Up. is it because of ambiguity?

Thank.

+1
source share
2 answers

method_callis a valid identifier. For example, some_callor my_call. Now imagine how much code would be broken if such identifiers were overridden operator"".

+1

, . operator"", - , :

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

(2.14.8.5):

5 L , , str ud- len - str ( , ). L

operator "" X (str, len)

-- (2.14.8.3) (2.14.8.4).

method_call, method .

+8

Source: https://habr.com/ru/post/1667459/


All Articles