# assignment operators in vtk

**URL:** <https://discourse.vtk.org/t/assignment-operators-in-vtk/15276>\
**Category:** Development\
**Tags:** code\
**Created:** [February 17, 2025, 4:38pm UTC](https://discourse.vtk.org/t/assignment-operators-in-vtk/15276 "2025-02-17T16:38:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![untereiner](https://discourse.vtk.org/user_avatar/discourse.vtk.org/untereiner/32/7561_2.png) [@untereiner](https://discourse.vtk.org/u/untereiner)\
**Post date:** [February 17, 2025, 4:38pm UTC](https://discourse.vtk.org/t/assignment-operators-in-vtk/15276/1 "2025-02-17T16:38:16Z")

</div>

Hello,

I was just wondering, because I don’t understand it.  
Is it ok for all deleted assignment operators in vtk classes to be written like this ?

```auto
void operator=(const T&) = delete;

```

Shouldn’t they be written this way to overload operator= ?

```auto
T& operator=(const T&) = delete;

```

is it ok for the objects to be movable by default ?

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)\
**Post date:** [February 18, 2025, 12:01pm UTC](https://discourse.vtk.org/t/assignment-operators-in-vtk/15276/2 "2025-02-18T12:01:32Z")

</div>

VTK doesn’t really “do” moves, but it probably isn’t safe (e.g., things the ctor constructs may not be reconstructible via methods to “restore” such a member to a valid state). I forget the rules of move operators and ctors…they might not be made at all given the set of other magic methods in VTK classes.

As for the operators, the return type can’t be overloaded, so it doesn’t really matter what it returns. There are a number of (suppressed) `clang-tidy` warnings around these methods anyways:

- the return type as you suggest
- that they are `private` (users first get the error that they are inaccessible, not that they are explicitly deleted)

---

<div class="post-metadata">

**Author:** ![untereiner](https://discourse.vtk.org/user_avatar/discourse.vtk.org/untereiner/32/7561_2.png) [@untereiner](https://discourse.vtk.org/u/untereiner)\
**Post date:** [February 18, 2025, 12:42pm UTC](https://discourse.vtk.org/t/assignment-operators-in-vtk/15276/3 "2025-02-18T12:42:31Z")

</div>

Thanks for your answers. I didn’t know that the return type doesn’t matter in the overload of a function declaration.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)\
**Post date:** [March 3, 2025, 11:04pm UTC](https://discourse.vtk.org/t/assignment-operators-in-vtk/15276/4 "2025-03-03T23:04:01Z")

</div>

Functions cannot be overloaded purely on return type, so there’s not really any point for `= delete` methods.
