    <rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:content="http://purl.org/rss/1.0/modules/content/">
     <channel>
        <title>ACCU  :: ACCU Standards Report</title>
        <link>https://members.accu.org/index.php/articles/2553</link>
        <description>Professionalism in Programming</description>
        <dc:language>en-us</dc:language> 
        <dc:creator>Administrator</dc:creator> 
        <admin:generatorAgent rdf:resource="http://www.xaraya.org" /> 
        <admin:errorReportsTo rdf:resource="mailto:webeditor@accu.org" />
       <sy:updatePeriod>hourly</sy:updatePeriod>
       <sy:updateFrequency>1</sy:updateFrequency>
       <docs>http://backend.userland.com/rss</docs>




<div class="xar-mod-head"><span class="xar-mod-title">Programming Topics + CVu Journal Vol 30, #4 - September 2018</span></div>

<table border="0" cellpadding="1" cellspacing="0">
    <tbody>
    <tr>
        <td valign="top">
            Browse in :
       </td>
       <td valign="top">

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c13/">Topics</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c65/">Programming</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/">All</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c76/">Journals</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c77/">CVu</a>

                     &gt;                         <a href="https://members.accu.org/index.php/articles/c390/">304</a>
<br />

                                            <a href="https://members.accu.org/index.php/articles/c65-390/">Any of these categories</a>

                    -                        <a href="https://members.accu.org/index.php/articles/c65+390/">All of these categories</a>
<br />
</td>
   </tr>
   </tbody>
</table>




<div class="xar-error">
   <p>
 <strong>Note:</strong> when you create a new publication type,
the articles module will automatically use the templates
<em>user-display-[publicationtype].xt</em>
and <em>user-summary-[publicationtype].xt</em>.
If those templates do not exist when you try to preview or display a new article,
you'll get this warning :-)  Please place your own templates in themes/<em>yourtheme</em>/modules/articles . The templates will get the extension .xt there. </p>
</div>
<div class="xar-norm xar-standard-box-padding">
   <h1><strong>Title:</strong>&nbsp;ACCU Standards Report</h1>
<p><strong>Author:</strong>&nbsp;Bob Schmidt</p>
<p>
<strong>Date:</strong> 04 September 2018 18:30:47 +01:00 or Tue, 04 September 2018 18:30:47 +01:00</p>
<p><strong>Summary:</strong>&nbsp;Emyr Williams reports the latest from the C++ Standards meetings.</p>
<p><strong>Body:</strong>&nbsp;<p>Sadly, I missed the deadline with my last report, which is entirely my fault. However, I hope to make up for it with the latest offering. The usual caveats apply. I would like to offer my everlasting thanks to Roger Orr for being kind enough to proof-read what Iâ€™ve written. Any errors that remain are mine alone.</p>

<p>First up, thereâ€™s been some news about new personnel in the ISO committee, with ACCUâ€™s Nina Ranns elected to be the WG21 secretary, which is awesome, along with ACCUâ€™s Code Critique master Roger Orr, who has been invited to join the direction group, which is a small by-invitation group of experienced participants who are asked to recommend priorities for WG21. So heartiest congratulations to them both.</p>

<p>So, over a week in June, the C++ ISO Committee met in Rapperswil, which is in Switzerland, hosted by HSR Rapperswil, ZÃ¼hlke, Netcetera, Bbv, SNV, Crealogix, Meeting C++ and BMW Car IT GmbH. It was well-attended, with 140 people at the meeting and 11 national bodies represented.</p>

<p>This was the penultimate meeting for merging major language features in to C++ 20, so priority was given to the larger proposals that could make C++ 20 or make solid progress towards making it in to C++ 20.</p>

<p>The second version of the Parallelism TS (N4725) is now finalised and, by the time this article is published, will be sent for publication by the various national bodies, including BSI, and people will be able to make use of it portably among compiler vendors that support it in their compilers.</p>

<p>The draft Reflection TS has been sent out to the national bodies for ballot. This is normally the final step before publication, and by the time the standards body meets again, the results of the ballot should be in and, if there are no glaring issues, they will move on towards publication.</p>

<p>Some of the highlights include:</p>

<h2>Contracts adopted for C++ 20 (P0380R1)</h2>

<p>This feature of the language provides a structured way to express function preconditions and postconditions in code.</p>

<p>For example, consider the following code snippet (with thanks to Jose Daniel Garcia Sanchez, the paperâ€™s author, for proof-reading my sample):</p>

<pre class="programlisting">
  double deposit(int account_number, 
    double deposit)
  [[expects: acount_number != 0 ]]
  [[ensures result: result &gt; 0 ]] 
  {
    double current_balance =
      get_balance(account_number);
    // this is within a function body,
    // so it can access everything within the
    // function itself.
    [[ assert: new_balance == 
      current_balance + deposit ]];
    return new_balance;
  }</pre>
  
<p>The contract is made up of three parts. There is the pre-condition (<code>expects</code>), the post-condition (<code>ensures</code>), and the assertion (<code>assert</code>). As can be seen from the above code sample, the post- and pre-conditions are defined outside of the function body, so they canâ€™t access the local variables within the function, other than any arguments that are passed to that function.</p>

<p>Contracts are also considered part of a functionâ€™s interface, and they operate on the external view of the function.</p>

<p>In his blog, Herb Sutter gives three points as to why contracts are a big deal. I wonâ€™t go in to detail in this article, but in essence they are:</p>

<ol>
	<li>Having decent contracts support is the first big step of reforming error handling in C++, and it will apply all the lessons learned over the last 30 years or so.</li>
	
	<li>It will allow for the gradual migration of <code>std::</code> standard library precondition violations from exceptions or error codes to contracts. It will also help to remove a majority of all exceptions thrown by the standard library.</li>
	
	<li>It will allow the language to consider handling out of memory differently from other errors. The LEWG voted unanimously to pursue section 4.3 of Herbâ€™s paper (P0709) which proposed a path of migrating all OOM from <code>bad_alloc</code> to <code>new(nothrow)</code>-like mechanisms.
	
		<p>The initial step, not for C++20 mind you, would be to change the default <code>new_handler</code> from throwing <code>bad_alloc</code> to calling <code>terminate</code>.</p>
	</li>
</ol>

<p>Itâ€™s worth noting that contracts are not permitted to perform an observable modification of an object. Itâ€™s also worth adding that this is the first step, for C++20, and the expectation is that the feature will be extended in the future.</p>

<h2>Class types in non-type template parameters (p0732)</h2>

<p>This change has been desired for a while. This would permit template non-type parameters of user-defined types, and enables instantiation templates with values such as compile-time strings.</p>

<p>Turns out that this is now possible due to a side benefit of the <code>&lt;=&gt;</code> spaceship comparison operator, which was proposed by Herb Sutter.</p>

<p>This is because the semantics of a defaulted <code>&lt;=&gt;</code> comparison is essential, because the compiler has to perform comparisons to determine whether or not the two template instantiations are the same. </p>

<h2>Feature test macros (p0941r2)</h2>

<p>This allows code to portably test whether certain new features in C++ exist. Now some may wonder â€œWhatâ€™s the point of that?â€ Well, the plan is that it will enable teams to adopt new C++ features before the compilers you use support them.</p>

<p>To use them youâ€™d write something like:</p>

<pre class="programlisting">
  #if __cpp_hex_float  // feature macro's name

    // modern code here...
  #else
    // do it the old way
  #endif</pre>
  
<p>Once youâ€™ve moved on to the newer compiler, you can drop the <code>#if</code> test and remove the entire <code>#else</code> block. So it ensures that your code is reasonably future proof, and backwards compatible for as long as you need it to be.</p>

<p>One key part of these macros is that these are <em>standardised</em> and can therefore replace a lot of the â€˜if gcc version &gt; <em>x</em> or if msvc version &gt; <code>y</code> or if clang version &gt; <em>z</em>â€™ tests.</p>

<h2>Explicit(bool) p0892r2</h2>

<p>This is a conditional explicit, along the lines as conditional <code>noexcept</code>. It lets library writers write <code>explicit</code> at a finer granularity, to turn off conversions where possible without having to write two functions at the same time.</p>

<p>When writing a class template which wraps a member of a template parameter type, itâ€™s useful to expose constructors that allow the user to construct the member in place.</p>

<h2>STL concepts</h2>

<p>The core features of concepts have already been accepted in to C++ 20, however the Evolutionary Working Group had another evening session on Concepts at the meeting in an attempt to resolve the issue of abbreviated function templates (AFTs).</p>

<p>The main issue was that given an AFT written using the Concepts TS syntax, such as (for example):</p>

<pre class="programlisting">
  void sort(Sortable &amp;s);</pre>
  
<p>itâ€™s not clear that this is a template. And it assumes that you know that <code>Sortable</code> is a concept and not a type.</p>

<p>Two proposals were presented. Herb Sutter presented an in-place syntax proposal (P0745r1) which the previous code sample, would be written:</p>

<pre class="programlisting">
  void sort (Sortable{} &amp;s);</pre>
  
<p>or</p>

<pre class="programlisting">
  void (Sortable{S}&amp; s);</pre>
  
<p>The proposal also proposed to change the constrained-parameter syntax to require braces for type parameters so that youâ€™d write instead:</p>

<pre class="programlisting">
  template&lt;Sortable{S}&gt; void sort(S&amp; s);</pre>
  
<p>The second proposal was Bjarne Stroustrupâ€™s minimal solution to concept syntax problems (p1079r0), which adds a single leading template keyword to announce that an ATF is a template:</p>

<pre class="programlisting">
  template void sort(Sortable&amp; s);</pre>
  
<p>This proposal leaves the constrained-parameter syntax alone.</p>

<p>Both proposals also have their downsides. Bjarneâ€™s proposal annotates the whole function rather than individual parameters so, for example, if you have a function with multiple parameters, you wonâ€™t know at a glance which parameter is a concept. Herbâ€™s proposal changes the constrained-parameter syntax.</p>

<p>Both proposals were well received by the EWG, and there will be further discussions about this in future meetings. However, there is now a new paper in the post meeting mailing, authored by Ville Voutilainen, P1141R0 entitled â€˜Yet another approach for constrained declarationsâ€™. But this will be discussed in the next report.</p>

<h2>Modules</h2>

<p>The committee saw a merged approach, which both major proposers said satisfies their requirements, that was met with enthusiasm in the room. The merged proposal (p1103r0) aims to combine the best of the Modules TS and the Atom alternative proposal, which was approved by the EWG.</p>

<p>The merged proposal accomplishes Atomâ€™s goal of providing a better mechanism for existing code bases to transition to Modules via a modularised legacy header. Essentially, existing headers that are not modules but are treated as if they are modules by the compiler. The merged proposal also retains the Modules TS mechanism of global module fragments with some restrictions, such as only allowing <code>#include</code>s and other preprocessor directives in the global module fragment.</p>

<p>Itâ€™s noteworthy, however, that the EWG didnâ€™t approve the poll to incorporate a subset of this merged proposal in to C++ 20 at this meeting. But this will be discussed in another meeting.</p>

<h2>Graphics</h2>

<p>At Jacksonville, the Graphics TS (p0267r8), which was set to contain 2D graphics primitives with a â€˜Cairoâ€™ inspired interface, ran in to some controversy. A number of folks had become convinced that, since this was something that professional graphics programmers/game developers were unlikely to use, the time required for a detailed wording review wouldnâ€™t be a good use of committee time.</p>

<p>As a result of this feeling, an evening session was held at the meeting to decide the future of the proposal. Initially, there was no overall consensus on whether or not the committee should proceed with ANY kind of graphics proposal.</p>

<p>Two papers were presented:</p>

<ul>
	<li>Bruce Adelstein Lelbach presented the Diet Graphics paper (p1062r0), which offered a rebuttal of the need for graphics support in the language but does propose a simple importing API;</li>
	
	<li>ACCUâ€™s own Guy Davidson also gave a presentation on the current graphics paper (p0267r8) along with some code snippets, and practical demonstrations.</li>
</ul>

<p>Guy also presented a paper (p0988) which detailed the history of the attempt to bring 2D graphics support into C++. Guy proposed two ways forwards: one was to kill the paper, and the other was to get confirmation that the committee still wanted to bring in 2D graphics support somehow.</p>

<p>This sadly led to no consensus being reached, and thus the graphics TS was abandoned for the time being.</p>

<p>At present itâ€™s my understanding that the BSI are pressing on with publishing the original graphics paper, so while it may not become an ISO standard for 2D graphics, it may become a BSI standard for 2D graphics.</p>

<p class="bio"><span class="author"><b>Emyr Williams</b></span>  Emyr Williams is a C++ developer who is on a mission to become a better programmer. His blog can be found at www.becomingbetter.co.uk</p>
</p>
<p><strong>Notes:</strong>&nbsp;</p>
<p><em>More fields may be available via dynamicdata ..</em></p>
</div>
</channel>
</rss>
