有没有办法可以在 C++ 中为 boost 向量重载“/”运算符?
#include <boost/assign.hpp>
#include <boost/numeric/ublas/vector.hpp>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/operations.hpp>
#include <boost/numeric/ublas/assignment.hpp>
namespace ublas = boost::numeric::ublas;
using namespace boost::assign;
template <typename T, typename U>
ublas::vector<T> operator/(U& var)
{
// do something here
return *this;
}
我看到像 Overloaded 'operator/' must be a binary operator 之类的错误(有 1 个参数)