add a few [[nodiscard]] to add warnings

The idea is to trigger a warning with that kind of code:

```c++
auto scale = traits.construct_scaled_vector_3_object();
auto translate = traits.construct_translated_point_3_object();

Vector_3 v = something();
scale(v, 2);  // should warn, because the correct code is
                    // `v = scale(v, 2)`
Point_3 p = whatever();
translate(p, v); // should be `p = translate(p, v)`
```

Maybe we should consider adding `[[nodiscard]]` to all
call operators of function objects of the kernel.

Or either add it to all the object types in the kernel.
This commit is contained in:
Laurent Rineau
2026-02-20 12:02:42 +01:00
parent 2e0f522c52
commit 31d466f5ae
@@ -3240,7 +3240,7 @@ public:
typedef typename K::Vector_2 Vector_2;
public:
Vector_2
[[nodiscard]] Vector_2
operator()( const Vector_2& v, const FT& c) const
{
return Vector_2(c * v.x(), c * v.y());
@@ -3254,7 +3254,7 @@ public:
typedef typename K::Vector_2 Vector_2;
public:
Vector_2
[[nodiscard]] Vector_2
operator()( const Vector_2& v, const FT& c) const
{
return Vector_2(v.x()/c, v.y()/c);
@@ -3268,7 +3268,7 @@ public:
typedef typename K::Vector_3 Vector_3;
public:
Vector_3
[[nodiscard]] Vector_3
operator()( const Vector_3& v, const FT& c) const
{
return Vector_3(v.x()/c, v.y()/c, v.z()/c);
@@ -3282,7 +3282,7 @@ public:
typedef typename K::Vector_3 Vector_3;
public:
Vector_3
[[nodiscard]] Vector_3
operator()( const Vector_3& w, const FT& c) const
{
return Vector_3(c * w.x(), c * w.y(), c * w.z());
@@ -3296,14 +3296,14 @@ public:
typedef typename K::Vector_2 Vector_2;
public:
Point_2
[[nodiscard]] Point_2
operator()( const Point_2& p, const Vector_2& v) const
{
typename K::Construct_point_2 construct_point_2;
return construct_point_2(p.x() + v.x(), p.y() + v.y());
}
Point_2
[[nodiscard]] Point_2
operator()( const Origin& , const Vector_2& v) const
{
typename K::Construct_point_2 construct_point_2;
@@ -3318,14 +3318,14 @@ public:
typedef typename K::Vector_3 Vector_3;
public:
Point_3
[[nodiscard]] Point_3
operator()( const Point_3& p, const Vector_3& v) const
{
typename K::Construct_point_3 construct_point_3;
return construct_point_3(p.x() + v.x(), p.y() + v.y(), p.z() + v.z());
}
Point_3
[[nodiscard]] Point_3
operator()( const Origin& , const Vector_3& v) const
{
typename K::Construct_point_3 construct_point_3;