Stack Overflow Asked on December 11, 2021
According to the GCC 8 Release Note, it is now possible to use std::char_traits<char>
and std::char_traits<wchar_t>
in constant expressions:
- Improved experimental support for C++17, including the following features:
- std::char_traits and std::char_traits<wchar_t> are usable in constant expressions.
What I understand here is you can’t use std::char_traits<char>
in constant expressions before GCC 8.
However, the following code compiles well with GCC 7.5:
#include <string_view>
int main() {
constexpr std::string_view sv{""};
constexpr std::size_t size = std::char_traits<char>::length(sv.data());
return 0;
}
So, is it possible to use std::char_traits in constant expressions before GCC 8? Or am I missing something?
This improvement was backported from mainline. It is available in the gcc 7 line from 7.3 onwards.
Answered by ecatmur on December 11, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP