Does the standard library permit users to specialize function objects like std::plus
and std::minus
for custom types?
If the answer to my first question is yes, are users allowed to change the declaration of the call operator? For example, since C++14 std::minus::operator() is declared as follows:
constexpr T operator()( const T& lhs, const T& rhs ) const;
Would it be legal to change this operator such that it is no longer constexpr
or returns double
instead of T?
namespace std
{
template <>
struct minus<MyArrayType>
{
double operator ()(const MyArrayType& x, const MyArrayType& y) const
{
return l2_norm(x - y);
}
};
} // std