fixstr::basic_fixed_string::size
fixstr::basic_fixed_string::length
#1 |
| |
#2 |
|
Returns the number of TChar
elements in the fixed string, i.e. std::distance(begin(), end())
.
note
For fixstr::fixed_string
, the elements are bytes (objects of type char
), which are not the same as characters if a multibyte encoding such as UTF-8 is used.
#
Parameters(none)
#
Return valueThe number of TChar
elements in the fixed string.
#
ComplexityConstant.
#
Example#include <fixed_string.hpp>#include <iterator>
int main(){ fixstr::fixed_string s = "Exemplar"; static_assert(s.size() == 8); static_assert(s.size() == s.length()); constexpr auto iterator_distance = static_cast<decltype(s)::size_type>(std::distance(s.begin(), s.end())); static_assert(s.size() == iterator_distance);
fixstr::fixed_u32string a = U"γγγΌγ»γ―γΌγ«γ"; // 8 code points static_assert(a.size() == 8); // 8 code units in UTF-32
fixstr::fixed_u16string b = u"γγγΌγ»γ―γΌγ«γ"; // 8 code points static_assert(b.size() == 8); // 8 code units in UTF-16
fixstr::fixed_string c = "γγγΌγ»γ―γΌγ«γ"; // 8 code points static_assert(c.size() == 24); // 24 code units in UTF-8
#if __cplusplus >= 202002 fixstr::fixed_u8string d = u8"γγγΌγ»γ―γΌγ«γ"; // 8 code points static_assert(d.size() == 24); // 24 code units in UTF-8#endif}