Matthew Woehlke
2018-11-30 19:58:54 UTC
(Apologies if this double-posts; I accidentally sent via gmane
originally, and posting that way is still problematic.)
Why can I not define a template UDL:
// Option 1
template <typename T, T... data>
inline Foo operator""_foo() { ... }
// Option 2
template <char... data
inline Foo operator""_foo() { ... }
...on a string?
"Hello, world!"_foo;
u"Hello, world!"_foo;
This seems like an asinine restriction, especially as at least GCC
already knows how to invoke the UDL:
foo.cpp: error: no matching function for call to
‘operator""_foo<char, 'H', 'e', 'l', 'l', 'o', ' ',
'w', 'o', 'r', 'l', 'd', '!'>()’
The only reason there is 'no matching function' is because the compiler
was not allowed to accept the UDL definition(s) as illustrated above:
foo.cpp: error: literal operator template
‘Foo operator""_foo()’ has invalid parameter list.
Expected non-type template argument pack <char...>
In fact, it's even worse; if I put e.g. a static_assert in the UDL body,
I can see that GCC is even *instantiating* the UDL as expected!
This is a stupid, pointless restriction. I propose we get rid of it.
Thoughts?
originally, and posting that way is still problematic.)
Why can I not define a template UDL:
// Option 1
template <typename T, T... data>
inline Foo operator""_foo() { ... }
// Option 2
template <char... data
inline Foo operator""_foo() { ... }
...on a string?
"Hello, world!"_foo;
u"Hello, world!"_foo;
This seems like an asinine restriction, especially as at least GCC
already knows how to invoke the UDL:
foo.cpp: error: no matching function for call to
‘operator""_foo<char, 'H', 'e', 'l', 'l', 'o', ' ',
'w', 'o', 'r', 'l', 'd', '!'>()’
The only reason there is 'no matching function' is because the compiler
was not allowed to accept the UDL definition(s) as illustrated above:
foo.cpp: error: literal operator template
‘Foo operator""_foo()’ has invalid parameter list.
Expected non-type template argument pack <char...>
In fact, it's even worse; if I put e.g. a static_assert in the UDL body,
I can see that GCC is even *instantiating* the UDL as expected!
This is a stupid, pointless restriction. I propose we get rid of it.
Thoughts?
--
Matthew
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1b65b95c-c3a7-9281-6af5-387e86765631%40gmail.com.
Matthew
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1b65b95c-c3a7-9281-6af5-387e86765631%40gmail.com.