Skip to content

Fix llvm9 not autoconverting int->double for variant

Paul Gessinger-Befurt requested to merge result-llvm9 into master

In llvm9 the following doesn't compile anymore:

struct S{};
std::variant<double, S> var{5}; 

This MR introduces additional check in the constructor and assignment operator of the Result type, and will then try to force a conversion from the given type T2 to either the value type T or the error type E in case:

  • T is not convertible to E or vice versa
  • T is not E
  • T2 is not convertible to T AND E at the same time

If this is the case, Result will try to convert to T if T2 is convertible to T or E if T2 is convertible to E.

Merge request reports