should methods be sfinae friendly?
sarah-ek opened this issue · 1 comments
sarah-ek commented
as things are right now, most of the methods on Option/Result
have well formed declarations, so the compilers thinks they can be invoked before peeking into their definition. as an example, this can be problematic for a user wishing to use SFINAE or concept constraints to dispatch to different algorithms in a templated context, as an example.
#include "stx/option.h"
struct S {};
using namespace stx;
static_assert(!equality_comparable<S, S>);
// succeeds?
static_assert(equality_comparable<Option<S>, Option<S>>);
constexpr auto a = Option<S>{};
constexpr auto b = Option<S>{};
// boo! fails when we actually use it
bool c = a == b;