diff --git a/include/cpp2util.h b/include/cpp2util.h index cffd93ac9..73124e563 100644 --- a/include/cpp2util.h +++ b/include/cpp2util.h @@ -356,6 +356,125 @@ using longdouble = long double; using _schar = signed char; // normally use i8 instead using _uchar = unsigned char; // normally use u8 instead +//----------------------------------------------------------------------- +// +// Helper for concepts +// +//----------------------------------------------------------------------- +// + +template +auto argument_of_helper(Ret(*) (Arg)) -> Arg; + +template +auto argument_of_helper(Ret(F::*) (Arg)) -> Arg; + +template +auto argument_of_helper(Ret(F::*) (Arg)&) -> Arg; + +template +auto argument_of_helper(Ret(F::*) (Arg)&&) -> Arg; + +template +auto argument_of_helper(Ret(F::*) (Arg) const) -> Arg; + +template +auto argument_of_helper(Ret(F::*) (Arg) const&) -> Arg; + +template +auto argument_of_helper(Ret(F::*) (Arg) const&&) -> Arg; + +template +auto argument_of_helper(F const&) -> CPP2_TYPEOF(argument_of_helper(&F::operator())); + +template +using argument_of_t = CPP2_TYPEOF(argument_of_helper(std::declval())); + +template +auto argument_of_helper_op_is(F const&) -> CPP2_TYPEOF(argument_of_helper(&F::op_is)); + +template +using argument_of_op_is_t = CPP2_TYPEOF(argument_of_helper_op_is(std::declval())); + +template +using pointee_t = std::iter_value_t; + +template