P3931R0: consteval all the non-allocating operator"" things
This paper makes all non-allocating operator"" in the standard library marked consteval. This doesn't break any code.
Motivation
Functions which don't have any runtime dependency and just creates an object should be consteval, unless they have some implicit external dependency, then they should be only constexpr, so they are still usable in constant evaluation.
Implementation
Basically just a replacement of constexpr with consteval in my fork of libc++.
No breakage
A dear reader can think this change will break some code by making pointers to these functions consteval-only values, but the standard already disallow us from taking address of most functions in the standard library, hence this is not a breakage.
Debugability
Any problematic code or a bug inside these functions will result in a compilation error instead runtime bug which needs to be debugged. This is seen as strict improvement, and even so users tends to prefer to skip over std:: namespaced functions when looking for bugs.
Wording
Note: only operator which is not changed is std::basic_string operators ""s as we still don't have non-transient allocation out of constant evaluation to runtime.
27.3.7 Suffix for basic_string_view literals [string.view.literals]
constexprconsteval string_view operator""sv(const char* str, size_t len) noexcept;
constexprconsteval u8string_view operator""sv(const char8_t* str, size_t len) noexcept;
constexprconsteval u16string_view operator""sv(const char16_t* str, size_t len) noexcept;
constexprconsteval u32string_view operator""sv(const char32_t* str, size_t len) noexcept;
constexprconsteval wstring_view operator""sv(const wchar_t* str, size_t len) noexcept;
29.4.11 Suffixes for complex number literals [complex.literals]
constexprconsteval complex<long double> operator""il(long double d);
constexprconsteval complex<long double> operator""il(unsigned long long d);
constexprconsteval complex<double> operator""i(long double d);
constexprconsteval complex<double> operator""i(unsigned long long d);
constexprconsteval complex<float> operator""if(long double d);
constexprconsteval complex<float> operator""if(unsigned long long d);
30.5.9 Suffixes for duration literals [time.duration.literals]
constexprconsteval chrono::hours operator""h(unsigned long long hours);
constexprconsteval chrono::duration<unspecified, ratio<3600, 1>> operator""h(long double hours);
constexprconsteval chrono::minutes operator""min(unsigned long long minutes);
constexprconsteval chrono::duration<unspecified, ratio<60, 1>> operator""min(long double minutes);
constexprconsteval chrono::seconds operator""s(unsigned long long sec);
constexprconsteval chrono::duration<unspecified> operator""s(long double sec);
constexprconsteval chrono::milliseconds operator""ms(unsigned long long msec);
constexprconsteval chrono::duration<unspecified, milli> operator""ms(long double msec);
constexprconsteval chrono::microseconds operator""us(unsigned long long usec);
constexprconsteval chrono::duration<unspecified, micro> operator""us(long double usec);
constexprconsteval chrono::nanoseconds operator""ns(unsigned long long nsec);
constexprconsteval chrono::duration<unspecified, nano> operator""ns(long double nsec);
30.8.3.3 Non-member functions [time.cal.day.nonmembers]
constexprconsteval chrono::day operator""d(unsigned long long d) noexcept;
30.8.5.3 Non-member functions [time.cal.year.nonmembers]
constexprconsteval chrono::year operator""y(unsigned long long y) noexcept;
Feature test macro
17.3.2 Header <version> synopsis [version.syn]
#define __cpp_lib_consteval_literals 20????L