As of C++20, the class template speciailization std::codecvt<char32_t, char, std::mbstate_t> is deprecated in favor of using char8_t: std::codecvt<char32_t, char8_t, std::mbstate_t>.
The line causing this warning is chrono.h. This warning was noticed when using llvm12 with libc++ in C++20 mode (c++2a) as libc++ marks the class template as deprecated per the C++20 spec.
Some notes regarding a potential patch for this:
- The
do_write function currently returns a std::string. One approach to solving this problem is to change this do_write function to work with char or char8_t consistently based on compiler support for char8_t. This would mean that the return type is now std::string or std::basic_string<char8_t>. Consider the following snippet:
#if defined(__cpp_char8_t)
using char_t = char8_t;
#else
using char_t = char;
#endif
auto&& os = std::basic_ostringstream<char_t>();
// Other code as-is
auto& f =
std::use_facet<std::codecvt<code_unit, char_t, std::mbstate_t>>(loc);
- The call to
std::time_put notably should use char still rather than char_t. There is no overload for std::time_put<char8_t> which is an oversight I think when char8_t got proposed. It can be added in a future paper which I may propose.
Note: I recommend working with char_t as described above throughout to avoid UB. While char and char8_t are the same size, alignment, etc, it is UB to reinterpret_cast different types (e.g. a std::string to a std::basic_string<char8_t>) for example as returned from the stringstream.str() call.
With the return type of do_write being a std::string or std::basic_string<char8_t> now, I don't yet know how this affects the calling code copies the string to the output iterator.
As of C++20, the class template speciailization
std::codecvt<char32_t, char, std::mbstate_t>is deprecated in favor of usingchar8_t:std::codecvt<char32_t, char8_t, std::mbstate_t>.The line causing this warning is chrono.h. This warning was noticed when using
llvm12withlibc++in C++20 mode (c++2a) aslibc++marks the class template as deprecated per the C++20 spec.Some notes regarding a potential patch for this:
do_writefunction currently returns astd::string. One approach to solving this problem is to change thisdo_writefunction to work withcharorchar8_tconsistently based on compiler support forchar8_t. This would mean that the return type is nowstd::stringorstd::basic_string<char8_t>. Consider the following snippet:std::time_putnotably should usecharstill rather thanchar_t. There is no overload forstd::time_put<char8_t>which is an oversight I think whenchar8_tgot proposed. It can be added in a future paper which I may propose.Note: I recommend working with
char_tas described above throughout to avoid UB. Whilecharandchar8_tare the same size, alignment, etc, it is UB toreinterpret_castdifferent types (e.g. astd::stringto astd::basic_string<char8_t>) for example as returned from thestringstream.str()call.With the return type of
do_writebeing astd::stringorstd::basic_string<char8_t>now, I don't yet know how this affects the calling code copies the string to the output iterator.