In 2013, N3599 tried adding literal operator templates for strings:template <typename CharT, ChartT ...c>auto operator"" _user_defined_literal();Unfortunately, the paper was rejected at the time on the basis of lacking propermachinery for compile-time string processing. Motivated by several use casesrequiring this literal operator (but no additional string processing machinery),I wrote a paper to try and revive this discussion with the committee.The latest draft of this paper is at [1]; please let me know of any comments.
On Sunday, August 14, 2016 at 1:11:31 PM UTC-7, Louis Dionne wrote:In 2013, N3599 tried adding literal operator templates for strings:template <typename CharT, ChartT ...c>auto operator"" _user_defined_literal();Unfortunately, the paper was rejected at the time on the basis of lacking propermachinery for compile-time string processing. Motivated by several use casesrequiring this literal operator (but no additional string processing machinery),I wrote a paper to try and revive this discussion with the committee.The latest draft of this paper is at [1]; please let me know of any comments.I'm wholly in favor of this idea, and the paper looks great. I would love to see this in '17, even though I suspect it's missed the boat.
In C++17, I wonder whether the idea of template<typename CharT, CharT... ch> operator""_udl is obsolete or archaic already. What if I've provided a template<auto... ch> operator""_udl, is that good enough? (Obvious literal answer: "no." But is there a good reason it shouldn't be? Bonus points if the good reason is something other than "compatibility/consistency with the C++11 version.")
Today I learned about htmlpreview.github.io, and it seems neat, but FYI, it breaks your link to http://cplusplus.github.io/EWG/ewg-active.html#66 by turning it into a link to https://htmlpreview.github.io/?https://github.com/ldionne/wg21/blob/master/generated/P0424R0.html#66 . Therefore you would do better to "publish" this draft by adding it to your gh-pages branch instead.(The htmlpreview bug is already filed: #43.)
On Sunday, 14 August 2016 22:22:16 UTC-7, Arthur O'Dwyer wrote:On Sunday, August 14, 2016 at 1:11:31 PM UTC-7, Louis Dionne wrote:In 2013, N3599 tried adding literal operator templates for strings:template <typename CharT, ChartT ...c>auto operator"" _user_defined_literal();Unfortunately, the paper was rejected at the time on the basis of lacking propermachinery for compile-time string processing. Motivated by several use casesrequiring this literal operator (but no additional string processing machinery),I wrote a paper to try and revive this discussion with the committee.The latest draft of this paper is at [1]; please let me know of any comments.I'm wholly in favor of this idea, and the paper looks great. I would love to see this in '17, even though I suspect it's missed the boat.I'm targeting C++20.
In C++17, I wonder whether the idea of template<typename CharT, CharT... ch> operator""_udl is obsolete or archaic already. What if I've provided a template<auto... ch> operator""_udl, is that good enough? (Obvious literal answer: "no." But is there a good reason it shouldn't be? Bonus points if the good reason is something other than "compatibility/consistency with the C++11 version.")I assume this could be made to work, but it might be slightly difficult to get the `CharT` type from just the `auto` parameter pack. We'd have to write a helper metafunction such astemplate <auto c, auto ...cs>struct type_of_first { using type = decltype(c); };Also, in case the parameter pack is empty (""_udl), we'd have no way to figure that type out.Today I learned about htmlpreview.github.io, and it seems neat, but FYI, it breaks your link to http://cplusplus.github.io/EWG/ewg-active.html#66 by turning it into a link to https://htmlpreview.github.io/?https://github.com/ldionne/wg21/blob/master/generated/P0424R0.html#66 . Therefore you would do better to "publish" this draft by adding it to your gh-pages branch instead.(The htmlpreview bug is already filed: #43.)Thanks a lot. In any case, I rewrote the proposal in Latex due to other feedback I received. You can find it attached.Regards,Louis
--
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+unsubscribe@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/67df98ef-c02d-484e-ac52-6a92c1b18778%40isocpp.org.
You can find it attached or at https://github.com/ldionne/wg21/blob/master/generated/D0424R0.pdf.
On Sunday, August 14, 2016 at 10:11:31 PM UTC+2, Louis Dionne wrote:Dear list,In 2013, N3599 tried adding literal operator templates for strings:template <typename CharT, ChartT ...c>auto operator"" _user_defined_literal();Unfortunately, the paper was rejected at the time on the basis of lacking propermachinery for compile-time string processing. Motivated by several use casesrequiring this literal operator (but no additional string processing machinery),I wrote a paper to try and revive this discussion with the committee.The latest draft of this paper is at [1]; please let me know of any comments.Regards,Louis DionneAFAIUI, one would then create a compile-time string wrapper, e.g. fixed_string (P0259R0), from the UDL-operator for any further processing.
There has also been the idea floating around of making regular string literals more amenable to compile-time computations, e.g. allowing them as template parameters, by implicitly converting them to (e.g) a fixed_string (or: like an initializer_list, that is magically constructed by the compiler). This would have the benefit of not having to "tag" (i.e. add _udl) any string (or any macros to hide the taggging...).
Therefore I'd be grateful for some clarification, whether the proposal should be considered in addition or instead of any future extensions in regular string literal handling. Do you believe that the presented approach is actually better (or actually worse), than upgrading regular string literals (which, AFAIK, hasn't been implemented anywhere yet)?