Skip to content

Operators should not be in the yarp::math namespace #1602

@drdanz

Description

@drdanz

Vector and Matrix operators are defined inside the yarp::math namespace.

namespace yarp
{
/**
* Mathematical operations.
*/
namespace math
{
/**
* Addition operator between a scalar and a vector (defined in Math.h).
* Sum the scalar to all the elements of the vector.
*/
YARP_math_API yarp::sig::Vector operator+(const yarp::sig::Vector &a, const double &s);

This means that, in order to perform an operation (for example Vector b = a + s;), the user has to add using namespace yarp::math; or to call the operator explicitly, i.e. (I think) something like this: Vector b = yarp::math::operator+(a, s);
The first option is considered bad practice, and the second option is just wrong.

I think we could just move them outside of the namespace, the only effect is if someone is using the second syntax, but I don't think anyone would be doing that...

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions