-
Notifications
You must be signed in to change notification settings - Fork 73
Open
Description
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&>());
struct NoCompare {}; // lacks comparison operators
// this assert fails, but equal comparison with tl::optional<NoCompare> doesn't compile
static_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
.
Metadata
Metadata
Assignees
Labels
No labels