std::basic_string_view<CharT,Traits>::size, std::basic_string_view<CharT,Traits>::length
: cppreference.com
<tbody>
</tbody>
constexpr size_type size() const noexcept; |
(C++17) | |
constexpr size_type length() const noexcept; |
(C++17) | |
CharT std::distance(begin(), end())
()
CharT
Run this code
#include <string_view>
#include <iostream>
void check_string(std::string_view ref)
{
//
//
std::cout << std::boolalpha
<< "'" << ref << "' has " << ref.size()
<< " character(s); emptiness: " << ref.empty() << '\n';
}
int main(int argc, char **argv)
{
//
check_string("");
// : argv[0]
if (argc > 0)
check_string(argv[0]);
}
:
'' has 0 character(s); emptiness: true
'./a.out' has 7 character(s); emptiness: false
| () | |
| () |