diff --git a/ostd/functional.hh b/ostd/functional.hh index b674d0e..dd22c58 100644 --- a/ostd/functional.hh +++ b/ostd/functional.hh @@ -47,6 +47,37 @@ OSTD_DEFINE_BINARY_OP(BitXor, ^, T) #undef OSTD_DEFINE_BINARY_OP +namespace detail { + template, char>::value> + struct CharEqual { + using FirstArgument = T *; + using SecondArgument = T *; + using Result = bool; + bool operator()(T *x, T *y) const { + return !strcmp(x, y); + } + }; + + template struct CharEqual { + using FirstArgument = T *; + using SecondArgument = T *; + using Result = bool; + bool operator()(T *x, T *y) const { + return x == y; + } + }; +} + +template struct EqualWithCstr { + using FirstArgument = T; + using SecondArgument = T; + bool operator()(const T &x, const T &y) const { + return x == y; + } +}; + +template struct EqualWithCstr: detail::CharEqual {}; + template struct LogicalNot { bool operator()(const T &x) const { return !x; } using Argument = T;