Namespaces
Variants
Views
Actions

std::codecvt::always_noconv, std::codecvt::do_always_noconv

From cppreference.com
< cpp‎ | locale‎ | codecvt
Revision as of 02:40, 25 November 2012 by 24.7.115.28 (Talk)

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <locale>
</td>

<td></td> <td></td> <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td >
public:
bool always_noconv() const
</td>

<td > (1) </td> <td class="t-dcl-nopad"> </td> </tr> <tr class="t-dcl-sep"><td></td><td></td><td></td></tr>

<tr class="t-dcl ">

<td >
protected:
bool do_always_noconv() const
</td>

<td > (2) </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

1) public member function, calls the member function do_always_noconv of the most derived class.

2) returns true if both Template:rlpf and Template:rlpf return std::codecvt_base::noconv for all valid inputs.

Contents

Return value

true if this conversion facet performs no conversions, false otherwise.

The non-converting specialization std::codecvt<char, char, std::mbstate_t> returns true

Notes

This function may be used e.g. in the implementation of std::basic_filebuf::underflow to use bulk character copy instead of calling std::codecvt::in if it is known that the locale imbued in the std::basic_filebuf does not perform any conversions.

Exceptions

noexcept specification:  
noexcept
  

Example

#include <locale>
#include <iostream>
int main()
{
    std::cout << "The non-converting char<->char codecvt::always_noconv() returns " 
              << std::boolalpha
              << std::use_facet<std::codecvt<char, char, std::mbstate_t>>(
                    std::locale()
                 ).always_noconv() << "\n"
              << "while wchar_t<->char codecvt::always_noconv() returns "
              << std::use_facet<std::codecvt<wchar_t, char, std::mbstate_t>>(
                    std::locale()
                 ).always_noconv() << "\n";
 
}

Output:

The non-converting char<->char codecvt::always_noconv() returns true
while wchar_t<->char codecvt::always_noconv() returns false