Port yuzu-emu/yuzu#4528: "common: Make use of [[nodiscard]] where applicable" (#5535)

Co-authored-by: LC <712067+lioncash@users.noreply.github.com>
This commit is contained in:
Tobias 2020-08-31 21:06:16 +02:00 committed by GitHub
parent e48110bdf4
commit f6b543886c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 284 additions and 265 deletions

View file

@ -135,8 +135,8 @@ public:
* containing several bitfields can be assembled by formatting each of their values and ORing
* the results together.
*/
static constexpr FORCE_INLINE StorageType FormatValue(const T& value) {
return ((StorageType)value << position) & mask;
[[nodiscard]] static constexpr StorageType FormatValue(const T& value) {
return (static_cast<StorageType>(value) << position) & mask;
}
/**
@ -144,7 +144,7 @@ public:
* (such as Value() or operator T), but this can be used to extract a value from a bitfield
* union in a constexpr context.
*/
static constexpr FORCE_INLINE T ExtractValue(const StorageType& storage) {
[[nodiscard]] static constexpr T ExtractValue(const StorageType& storage) {
if constexpr (std::numeric_limits<UnderlyingType>::is_signed) {
std::size_t shift = 8 * sizeof(T) - bits;
return static_cast<T>(static_cast<UnderlyingType>(storage << (shift - position)) >>
@ -168,7 +168,7 @@ public:
constexpr BitField(BitField&&) noexcept = default;
constexpr BitField& operator=(BitField&&) noexcept = default;
constexpr operator T() const {
[[nodiscard]] constexpr operator T() const {
return Value();
}
@ -176,11 +176,11 @@ public:
storage = (static_cast<StorageType>(storage) & ~mask) | FormatValue(value);
}
constexpr T Value() const {
[[nodiscard]] constexpr T Value() const {
return ExtractValue(storage);
}
constexpr explicit operator bool() const {
[[nodiscard]] constexpr explicit operator bool() const {
return Value() != 0;
}