<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/67983>67983</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Missing constraints on operator<< for chrono::sys_time
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jwakely
</td>
</tr>
</table>
<pre>
https://reviews.llvm.org/D144739 (committed as https://github.com/llvm/llvm-project/commit/2c1d79596fe7d0f5fc71abb76a74c8a603fc8a21) added `operator<<` for `chrono::sys_time` but it's missing the constraints:
> _Constraints_: `treat_as_floating_point_v<typename Duration::rep>` is `false`, and `Duration{1} <
days{1}` is `true`.
That means the following program fails because the overloads are ambiguous:
```c++
#include <iostream>
#include <chrono>
namespace date {
template <class Duration>
using sys_time = std::chrono::time_point<std::chrono::system_clock, Duration>;
template <class CharT, class Traits, class Duration>
inline
std::basic_ostream<CharT, Traits>&
operator<<(std::basic_ostream<CharT, Traits>& os, const sys_time<Duration>& tp)
{
return os << 123;
}
}
using namespace date;
int
main ()
{
auto now = std::chrono::system_clock::now ();
std::cout << now << std::endl;
}
```
This compiles with `-stdlib=libstdc++` but not `-stdlib=libc++`
CC @mordante
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVU2P6yoM_TVkY90qgTZpFlnMpNPd282-coC23EsgwmSq_vsnkn7e6dPTSFELGB-OfYxBInNwWjds9c5WmwzHePSh-X3CP9qes86rc3OMcSAm3hjfMr4N-svoEy2s_eoXPhwY326K5bISNTC-lr7vTYxaARI8Ox5MPI7dQvqe8W3yvvz9GoL_rWVkfDt7M77lslBVvarLva5Uvl_tZVVg11UlVku5xjIXe7lGXjBeAyqlFbAy94MOGH1gok1fmcPeh2SQx-CdT0TEG51pF02vk7kbI6TjKoLeEBl3gHjUIL2jGNC4OJHPNyy__ooP2LV3846Jt3RADBrjDmm3tx6jcYfd4I2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