public member function
<locale>

std::codecvt::max_length

int max_length() const throw();
int max_length() const noexcept;
Return max length of one character
Returns the maximum number of internal characters needed for an external character.

Internally, this function simply calls the virtual protected member do_max_length</samp to produce its result.

Parameters

none

Return value

The maximum length of one external character if translated to internal characters.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// codecvt::max_length example
#include <iostream>       // std::cout
#include <locale>         // std::locale, std::codecvt, std::use_facet

int main ()
{
  std::locale loc;

  std::cout << "max_length for codecvt<char,char,mbstate_t>: ";
  std::cout << std::use_facet<std::codecvt<char,char,mbstate_t> >(loc).max_length();
  std::cout << '\n';

  std::cout << "max_length for codecvt<wchar_t,char,mbstate_t>: ";
  std::cout << std::use_facet<std::codecvt<wchar_t,char,mbstate_t> >(loc).max_length();
  std::cout << '\n';

  return 0;
}

Possible output:

max_length for codecvt<char,char,mbstate_t>: 1
max_length for codecvt<wchar_t,char,mbstate_t>: 5


Data races

The facet object is accessed.

Exception safety

No-throw guarantee: never throws exceptions.

See also