You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checking with templates whether tl::optional<T> is comparable returns the wrong result, if T is not comparable (check works with std::optional). For example:
#include<experimental/type_traits>template <typename T, typename U>
using equality_comparison = decltype(std::declval<T const&>() == std::declval<U const&>());
structNoCompare {}; // lacks comparison operators// this assert fails, but equal comparison with tl::optional<NoCompare> doesn't compilestatic_assert(!std::experimental::is_detected<equality_comparison, tl::optional<NoCompare>, NoCompare>::value,
"'tl::optional<NoCompare> == NoCompare' should not compile");
Note: I ran into this issue using tl::optional with Trompeloil (https://github.com/rollbear/trompeloeil), as Trompeloil checks this way whether function parameters are comparable to nullptr.
The text was updated successfully, but these errors were encountered:
I suggest to solve this issue by adding enable_if to the comparison operators, to propagate the comparison trait of T and U to the tl::optional comparison operators.
Checking with templates whether
tl::optional<T>
is comparable returns the wrong result, ifT
is not comparable (check works withstd::optional
). For example:Note: I ran into this issue using
tl::optional
with Trompeloil (https://github.com/rollbear/trompeloeil), as Trompeloil checks this way whether function parameters are comparable tonullptr
.The text was updated successfully, but these errors were encountered: