#555·EASTL

operator/(duration, duration) cannot be used

Author: mtnpkeCreated Jan 28, 2025Updated Jan 28, 2025

Trying to invoke operator/(duration, duration) yields to compile errors on MSVC because it tries to instantiate the other overload - operator/(duration, number) - and fails in determining the common_type of the arguments. This failure is fatal because EASTL includes the original C++11 common_type definition that is not SFINAE-friendly. This was later acknowledged in N3843 and fixed for C++17 in LWG2408.

(This is irrespective of and a separate issue to #554)

Example code:

cpp
seconds s(5);
milliseconds ms(10);
auto result{s / ms}; // added as line 107 in TestChrono.cpp; see below

Error message:

C:\_GIT\EASTL\include\EASTL\internal\type_compound.h(640): error C2446: ':': no conversion from 'T' to 'T'
          with
          [
              T=eastl::chrono::milliseconds
          ]
          and
          [
              T=__int64
          ]
  C:\_GIT\EASTL\include\EASTL/internal/type_compound.h(640): note: the template instantiation context (the oldest one first) is
  C:\_GIT\EASTL\test\source\TestChrono.cpp(107): note: see reference to function template instantiation 'eastl::chrono::duration<eastl::common_type<Rep1,Rep2>::type,Period1> eastl::chrono::operator /(const eastl::chrono::duration<Rep,Period> &,const Rep2 &)' being compiled
  C:\_GIT\EASTL\test\source\TestChrono.cpp(107): note: see reference to class template instantiation 'eastl::common_type<__int64,eastl::chrono::milliseconds>' being compiled
C:\_GIT\EASTL\include\EASTL\internal\type_compound.h(640): error C2062: type 'unknown-type' unexpected
C:\_GIT\EASTL\include\EASTL\internal\type_compound.h(640): error C2238: unexpected token(s) preceding ';'

Compiler version: Microsoft (R) C/C++ Optimizing Compiler Version 19.40.33817 for x64