Change the result of `operator=` on `Mod` to return `Mod&`.  In this
example:

```c++
Mod<4, int> a;
int b = (a = 8);
```

The value of `b` will now be 0, not 8, and will equal the value of `a`.
Hopefully this is less confusing to users of this class.
This commit is contained in:
David Chisnall 2019-04-29 15:14:43 +01:00
Родитель 22d33ebf99
Коммит b5bc09ced3
2 изменённых файлов: 9 добавлений и 3 удалений

Просмотреть файл

@ -1 +1,7 @@
Checks: '-*,clang-diagnostic-*,google-readability-casting,readability-else-after-return,performance-unnecessary-copy-initialization,bugprone-use-after-move,modernize-use-nullptr'
Checks: '-*,clang-diagnostic-*,google-readability-casting,readability-else-after-return,performance-unnecessary-copy-initialization,bugprone-use-after-move,modernize-use-nullptr,modernize-redundant-void-arg,modernize-return-braced-init-list,modernize-use-default-member-init,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-nodiscard,modernize-use-override,cppcoreguidelines-avoid-goto,misc-unconventional-assign-operator'
# It would be nice to enable:
# - readability-magic-numbers
# - modernize-avoid-c-arrays
CheckOptions:
- key: modernize-use-default-member-init.UseAssignment
value: '1'

Просмотреть файл

@ -53,10 +53,10 @@ namespace snmalloc
return static_cast<T>(value & (length - 1));
}
T& operator=(const T v)
Mod& operator=(const T v)
{
value = v;
return value;
return *this;
}
};