std::codecv...,do_unshift(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸŽ€ std::codecv...,do_unshift(3) β€” C++ Standard Libary manual, bestie! πŸ’–

Okay so welcome to the manual page for std::codecvt::unshift and do_unshift, straight from the <purple>C++ Standard Libary</purple>. This is your group-chat explainer for conversion states, and we are keeping every parameter and every weird little detail. No skipping, no cap. πŸ¦‹

🌸 NAME

std::codecvt::unshift,do_unshift β€” yep, the name is literally std::codecvt::unshift,do_unshift, and it is giving β€œrepetition is the brand.” πŸ’…

πŸ¦‹ Synopsis

Defined in header <locale>.

public:

result unshift( StateT& state, ExternT* to, ExternT* to_end,
                ExternT*& to_next ) const;

(1) β€” public member function: calls the member function do_unshift of the most derived class. πŸ’–

protected:

virtual result do_unshift( StateT& state, ExternT* to, ExternT* to_end,
                           ExternT*& to_next ) const;

(2) β€” if the encoding represented by this codecvt facet is state-dependent, and state represents a conversion state that is not the initial shift state, writes the characters necessary to return to the initial shift state. The characters are written to a character array whose first element is pointed to by to. No more than to_end - to characters are written. The parameter to_next is updated to point one past the last character written. πŸ¦‹

πŸ’– Return value

It returns a value of type std::codecvt_base::result, and that result tells you the success status, like a little vibe check for the conversion:

  • ok β€” all necessary characters were written. state now represents initial shift state. ✨
  • partial β€” not enough space in the output buffer. to_next == to_end. 😭
  • error β€” an unspecified error has occurred. πŸ’€
  • noconv β€” the encoding is not state-dependent, no termination sequence necessary. πŸŽ€

🧚 Notes

This function is called by std::basic_filebuf::close() and in other situations when finalizing a state-dependent multibyte character sequence. 🫢

πŸ“ Example

This section is incomplete. Reason: no example.

πŸ’€ Defect reports

The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

  • LWG 305 β€” Applied to: C++98. Behavior as published: std::codecvt<wchar_t, char, std::mbstate_t>::do_unshift was required not to write any character. Correct behavior: not required.
  • LWG 380 β€” Applied to: C++98. Behavior as published: the meaning of returning partial was 'more characters need to be supplied to complete termination', but no character is supplied. Correct behavior: corrected to indicating insufficient buffer space.
  • LWG 381 β€” Applied to: C++98. Behavior as published: state was not required to be valid, and error is returned if state is invalid. Correct behavior: state is required to be valid, and returning error indicates an error.
  • LWG 664 β€” Applied to: C++98. Behavior as published: std::codecvt<char, char, std::mbstate_t>::do_unshift was required not to write any character. Correct behavior: not required.
  • LWG 665 β€” Applied to: C++98. Behavior as published: std::codecvt<char, char, std::mbstate_t>::do_unshift was required to return noconv. Correct behavior: not required.

🌈 See also

  • wcrtomb β€” converts a wide character to its multibyte representation, given state (function).
  • do_out β€” converts a string from InternT to ExternT, such as when writing to file [virtual] (virtual protected member function).

🏷️ Category

  • * Todo no example

πŸ’– That is the whole page, bestie β€” source/version: http://cppreference.com, date: 2024.06.10. Go finalize those state-dependent sequences and slay, periodt. 🫢

πŸ“¦ where this page comes from