<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2175: wstring_convert and wbuffer_convert validity</title>
<meta property="og:title" content="Issue 2175: wstring_convert and wbuffer_convert validity">
<meta property="og:description" content="C++ library issue. Status: C++14">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2175.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#C++14">C++14</a> status.</em></p>
<h3 id="2175"><a href="lwg-defects.html#2175">2175</a>. <code>wstring_convert</code> and <code>wbuffer_convert</code> validity</h3>
<p><b>Section:</b> 99 [depr.conversions.string], 99 [depr.conversions.buffer] <b>Status:</b> <a href="lwg-active.html#C++14">C++14</a>
 <b>Submitter:</b> Jonathan Wakely <b>Opened:</b> 2012-08-02 <b>Last modified:</b> 2017-09-07</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View other</b> <a href="lwg-index-open.html#depr.conversions.string">active issues</a> in [depr.conversions.string].</p>
<p><b>View all other</b> <a href="lwg-index.html#depr.conversions.string">issues</a> in [depr.conversions.string].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++14">C++14</a> status.</p>
<p><b>Discussion:</b></p>

<p>
See discussion following <a href="http://listarchives.isocpp.org/cgi-bin/wg21/message?wg=lib&amp;msg=32710">c++std-lib-32710</a>.
<p/>
It's not specified what happens if <code>wstring_convert</code> and <code>wbuffer_convert</code> objects are constructed 
with null <code>Codecvt</code> pointers.
<p/>
Should the constructors have preconditions that the pointers are not null?  If not, are conversions expected to 
fail, or is it undefined to attempt conversions if the pointers are null?
<p/>
There are no observer functions to check whether objects were constructed with valid <code>Codecvt</code> pointers. 
If the types are made movable such observers would be necessary even if the constructors require non-null 
pointers (see also LWG <a href="lwg-defects.html#2176" title="Special members for wstring_convert and wbuffer_convert (Status: C++14)">2176</a><sup><a href="https://cplusplus.github.io/LWG/issue2176" title="Latest snapshot">(i)</a></sup>).
</p>

<p><i>[2013-03-15 Issues Teleconference]</i></p>

<p>
Moved to Tentatively Ready.
</p>

<p><i>[2013-04-20 Bristol]</i></p>




<p id="res-2175"><b>Proposed resolution:</b></p>
<p>This wording is relative to N3376.</p>

<ol>
<li><p>Insert a new paragraph before  [conversions.string] paragraph 16:</p>

<blockquote><pre>
wstring_convert(Codecvt *pcvt = new Codecvt);
wstring_convert(Codecvt *pcvt, state_type state);
wstring_convert(const byte_string&amp; byte_err,
  const wide_string&amp; wide_err = wide_string());
</pre>
<blockquote>
<p>
<ins>-?- <i>Requires</i>: For the first and second constructors <code>pcvt != nullptr</code>.</ins>
<p/>
-16- <i>Effects</i>: The first constructor shall store <code>pcvt</code> in <code>cvtptr</code> and default values in 
<code>cvtstate</code>, <code>byte_err_string</code>, and <code>wide_err_string</code>. The second constructor shall 
store <code>pcvt</code> in <code>cvtptr</code>, <code>state</code> in <code>cvtstate</code>, and default values in 
<code>byte_err_string</code> and <code>wide_err_string</code>; moreover the stored state shall be retained between 
calls to <code>from_bytes</code> and <code>to_bytes</code>. The third constructor shall store <code>new Codecvt</code> 
in <code>cvtptr</code>, <code>state_type()</code> in cvtstate, <code>byte_err</code> in <code>byte_err_string</code>, 
and <code>wide_err</code> in <code>wide_err_string</code>.
</p>
</blockquote></blockquote>
</li>

<li><p>Insert a new paragraph before  [conversions.buffer] paragraph 10:</p>

<blockquote><pre>
wbuffer_convert(std::streambuf *bytebuf = 0,
  Codecvt *pcvt = new Codecvt, state_type state = state_type());
</pre><blockquote>
<p>
<ins>-?- <i>Requires</i>: <code>pcvt != nullptr</code>.</ins>
<p/>
-10- <i>Effects</i>: The constructor constructs a stream buffer object, initializes <code>bufptr</code> to <code>bytebuf</code>, 
initializes <code>cvtptr</code> to <code>pcvt</code>, and initializes <code>cvtstate</code> to <code>state</code>.
</p>
</blockquote></blockquote>

</li>

</ol>





</body>
</html>
