<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3145: file_clock breaks ABI for C++17 implementations</title>
<meta property="og:title" content="Issue 3145: file_clock breaks ABI for C++17 implementations">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3145.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++20">C++20</a> status.</em></p>
<h3 id="3145"><a href="lwg-defects.html#3145">3145</a>. <code>file_clock</code> breaks ABI for C++17 implementations</h3>
<p><b>Section:</b> 30.7.6 <a href="https://wg21.link/time.clock.file">[time.clock.file]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Billy Robert O'Neal III <b>Opened:</b> 2018-07-26 <b>Last modified:</b> 2021-02-25</p>
<p><b>Priority: </b>1
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++20">C++20</a> status.</p>
<p><b>Discussion:</b></p>
<p>
It was pointed out in one of Eric's changes to libc++ <a href="https://reviews.llvm.org/D49774">here</a> that 
<a href="https://wg21.link/p0355">P0355</a> adds <code>file_clock</code>, which is intended to be the clock used for 
<code>std::filesystem::file_time_type</code>'s clock.
<p/>
Unfortunately, this is an ABI break for implementations that are already shipping C++17 filesystem that did not 
call their clock type <code>std::file_clock</code>. For example, MSVC++'s is called <code>std::filesystem::_File_time_clock</code>.
<p/>
We can keep much the same interface of <a href="https://wg21.link/p0355">P0355</a> by making <code>file_clock</code> 
a typedef for an unspecified type. This technically changes the associated namespaces for expressions using that 
clock for the sake of ADL, but I can't imagine a user who cares, as clocks aren't generally called in ADL-able 
expressions, <code>duration</code>s and <code>time_point</code>s are.
</p>

<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">
<p>
This wording is relative to <a href="https://wg21.link/n4750">N4750</a>.
</p>

<ol>
<li>
<p>Change 30.2 <a href="https://wg21.link/time.syn">[time.syn]</a>, header <code>&lt;chrono&gt;</code> synopsis, as indicated:</p>

<blockquote>
<pre>
[&hellip;]
<i>// 30.7.6 <a href="https://wg21.link/time.clock.file">[time.clock.file]</a>, <del>class</del><ins>type</ins> file_clock</i>
<del>class</del><ins>using</ins> file_clock <ins>= <i>unspecified</i></ins>;
[&hellip;]
</pre>
</blockquote>
</li>

<li>
<p>Change 30.7.6 <a href="https://wg21.link/time.clock.file">[time.clock.file]</a> as indicated:</p>

<blockquote>
<p>
<b>23.17.7.5 <del>Class</del><ins>Type</ins> <code>file_clock</code> [time.clock.file]</b>
</p>
</blockquote>
</li>

<li>
<p>Change 30.7.6.1 <a href="https://wg21.link/time.clock.file.overview">[time.clock.file.overview]</a>, class <code>file_clock</code> synopsis, as indicated:</p>

<blockquote>
<pre>
namespace std::chrono {
  <ins>using file_clock = <i>see below</i>;</ins>
  <del>class file_clock {
  public:
    using rep = <i>a signed arithmetic type</i>;
    using period = ratio&lt;<i>unspecified</i>, <i>unspecified</i>&gt;;
    using duration = chrono::duration&lt;rep, period&gt;;
    using time_point = chrono::time_point&lt;file_clock&gt;;
    static constexpr bool is_steady = <i>unspecified</i>;
    
    static time_point now() noexcept;
    
    <i>// Conversion functions, see below</i>
  };</del>
}
</pre>
<p>
-1- <del>The clock</del> <code>file_clock</code> <ins>is an alias for a type meeting the <code>TrivialClock</code> requirements 
(30.3 <a href="https://wg21.link/time.clock.req">[time.clock.req]</a>), uses a signed arithmetic type for <code>file_clock::rep</code>, and</ins> is used to create the 
<code>time_point</code> system used for <code>file_time_type</code> (31.12 <a href="https://wg21.link/filesystems">[filesystems]</a>). Its epoch is unspecified.
<ins>[<i>Note:</i> The type <code>file_clock</code> denotes may be in a different namespace than <code>std::chrono</code>, 
such as <code>std::filesystem</code>. &mdash; <i>end note</i>]</ins>
</p>
</blockquote>
</li>

<li>
<p>Change 30.7.6.2 <a href="https://wg21.link/time.clock.file.members">[time.clock.file.members]</a> as indicated:</p>

<blockquote>
<pre>
<del>static time_point now();</del>
</pre>
<blockquote>
<p>
<del>-1- <i>Returns:</i> A <code>file_clock::time_point</code> indicating the current time.</del>
<p/>
-2- The class <del><code>file_clock</code> shall</del><ins>type denoted by <code>file_clock</code></ins> provide<ins>s</ins> 
precisely one of the following two sets of static member functions: [&hellip;]
</p>
</blockquote>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2018-07-30 Priority set to 1 after reflector discussion; wording updates based on several discussion contributions.]</i></p>


<p><strong>Previous resolution [SUPERSEDED]:</strong></p>
<blockquote class="note">
<p>
This wording is relative to <a href="https://wg21.link/n4762">N4762</a>.
</p>

<ol>
<li>
<p>Change 30.2 <a href="https://wg21.link/time.syn">[time.syn]</a>, header <code>&lt;chrono&gt;</code> synopsis, as indicated:</p>

<blockquote>
<pre>
[&hellip;]
<i>// 30.7.6 <a href="https://wg21.link/time.clock.file">[time.clock.file]</a>, <del>class</del><ins>type</ins> file_clock</i>
<del>class</del><ins>using</ins> file_clock <ins>= <i>see below</i></ins>;
[&hellip;]
</pre>
</blockquote>
</li>

<li>
<p>Change 30.7.6 <a href="https://wg21.link/time.clock.file">[time.clock.file]</a> as indicated:</p>

<blockquote>
<p>
<b>23.17.7.5 <del>Class</del><ins>Type</ins> <code>file_clock</code> [time.clock.file]</b>
</p>
</blockquote>
</li>

<li>
<p>Change 30.7.6.1 <a href="https://wg21.link/time.clock.file.overview">[time.clock.file.overview]</a>, class <code>file_clock</code> synopsis, as indicated:</p>

<blockquote>
<pre>
namespace std::chrono {
  <ins>using file_clock = <i>see below</i>;</ins>
  <del>class file_clock {
  public:
    using rep = <i>a signed arithmetic type</i>;
    using period = ratio&lt;<i>unspecified</i>, <i>unspecified</i>&gt;;
    using duration = chrono::duration&lt;rep, period&gt;;
    using time_point = chrono::time_point&lt;file_clock&gt;;
    static constexpr bool is_steady = <i>unspecified</i>;
    
    static time_point now() noexcept;
    
    <i>// Conversion functions, see below</i>
  };</del>
}
</pre>
<p>
-1- <del>The clock</del> <code>file_clock</code> <ins>is an alias for a type meeting the <code>TrivialClock</code> requirements 
(30.3 <a href="https://wg21.link/time.clock.req">[time.clock.req]</a>), which uses a signed arithmetic type for <code>file_clock::rep</code>. 
<code>file_clock</code></ins> is used to create the <code>time_point</code> system used for <code>file_time_type</code> 
(31.12 <a href="https://wg21.link/filesystems">[filesystems]</a>). Its epoch is unspecified<ins>, and <code>noexcept(file_clock::now())</code> is 
<code>true</code></ins>. <ins>[<i>Note:</i> The type <code>file_clock</code> denotes may be in a different namespace 
than <code>std::chrono</code>, such as <code>std::filesystem</code>. &mdash; <i>end note</i>]</ins>
</p>
</blockquote>
</li>

<li>
<p>Change 30.7.6.2 <a href="https://wg21.link/time.clock.file.members">[time.clock.file.members]</a> as indicated:</p>

<blockquote>
<pre>
<del>static time_point now();</del>
</pre>
<blockquote>
<p>
<del>-1- <i>Returns:</i> A <code>file_clock::time_point</code> indicating the current time.</del>
<p/>
-2- The class <del><code>file_clock</code> shall</del><ins>type denoted by <code>file_clock</code></ins> provide<ins>s</ins> 
precisely one of the following two sets of static member functions: [&hellip;]
</p>
</blockquote>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2018-08-23 Batavia Issues processing: Minor wording changes, and status to "Tentatively Ready".]</i></p>


<p><i>[2018-11, Adopted in San Diego]</i></p>



<p id="res-3145"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/n4762">N4762</a>.
</p>

<ol>
<li>
<p>Change 30.2 <a href="https://wg21.link/time.syn">[time.syn]</a>, header <code>&lt;chrono&gt;</code> synopsis, as indicated:</p>

<blockquote>
<pre>
[&hellip;]
<i>// 30.7.6 <a href="https://wg21.link/time.clock.file">[time.clock.file]</a>, <del>class</del><ins>type</ins> file_clock</i>
<del>class</del><ins>using</ins> file_clock <ins>= <i>see below</i></ins>;
[&hellip;]
</pre>
</blockquote>
</li>

<li>
<p>Change 30.7.6 <a href="https://wg21.link/time.clock.file">[time.clock.file]</a> as indicated:</p>

<blockquote>
<p>
<b>23.17.7.5 <del>Class</del><ins>Type</ins> <code>file_clock</code> [time.clock.file]</b>
</p>
</blockquote>
</li>

<li>
<p>Change 30.7.6.1 <a href="https://wg21.link/time.clock.file.overview">[time.clock.file.overview]</a>, class <code>file_clock</code> synopsis, as indicated:</p>

<blockquote>
<pre>
namespace std::chrono {
  <ins>using file_clock = <i>see below</i>;</ins>
  <del>class file_clock {
  public:
    using rep = <i>a signed arithmetic type</i>;
    using period = ratio&lt;<i>unspecified</i>, <i>unspecified</i>&gt;;
    using duration = chrono::duration&lt;rep, period&gt;;
    using time_point = chrono::time_point&lt;file_clock&gt;;
    static constexpr bool is_steady = <i>unspecified</i>;
    
    static time_point now() noexcept;
    
    <i>// Conversion functions, see below</i>
  };</del>
}
</pre>
<p>
-1- <del>The clock</del> <code>file_clock</code> <ins>is an alias for a type meeting the <code>Cpp17TrivialClock</code> requirements 
(30.3 <a href="https://wg21.link/time.clock.req">[time.clock.req]</a>), and using a signed arithmetic type for <code>file_clock::rep</code>. 
<code>file_clock</code></ins> is used to create the <code>time_point</code> system used for <code>file_time_type</code> 
(31.12 <a href="https://wg21.link/filesystems">[filesystems]</a>). Its epoch is unspecified<ins>, and <code>noexcept(file_clock::now())</code> is 
<code>true</code></ins>. <ins>[<i>Note:</i> The type that <code>file_clock</code> denotes may be in a different namespace 
than <code>std::chrono</code>, such as <code>std::filesystem</code>. &mdash; <i>end note</i>]</ins>
</p>
</blockquote>
</li>

<li>
<p>Change 30.7.6.2 <a href="https://wg21.link/time.clock.file.members">[time.clock.file.members]</a> as indicated:</p>

<blockquote>
<pre>
<del>static time_point now();</del>
</pre>
<blockquote>
<p>
<del>-1- <i>Returns:</i> A <code>file_clock::time_point</code> indicating the current time.</del>
<p/>
-2- The type <del><code>file_clock</code> shall</del><ins>type denoted by <code>file_clock</code></ins> provide<ins>s</ins> 
precisely one of the following two sets of static member functions: [&hellip;]
</p>
</blockquote>
</blockquote>
</li>
</ol>





</body>
</html>
