Replace static_cast<void>() with [[maybe_unused]] attribute (#5892)

This clarifies intent. Not done for thirdparty libraries or
structured binding variables.
This commit is contained in:
Tyler Veness
2023-11-08 12:47:23 -08:00
committed by GitHub
parent 70392cbbcb
commit 3a1194be40
7 changed files with 23 additions and 55 deletions

View File

@@ -16,20 +16,17 @@ class MoveOnlyType {
} // namespace
TEST(ArrayTest, CopyableTypeCompiles) {
constexpr wpi::array<int, 3> arr1{1, 2, 3};
static_cast<void>(arr1);
[[maybe_unused]] constexpr wpi::array<int, 3> arr1{1, 2, 3};
// Test deduction guide
constexpr wpi::array arr2{1, 2, 3};
static_cast<void>(arr2);
[[maybe_unused]] constexpr wpi::array arr2{1, 2, 3};
}
TEST(ArrayTest, MoveOnlyTypeCompiles) {
constexpr wpi::array<MoveOnlyType, 3> arr1{MoveOnlyType{}, MoveOnlyType{},
MoveOnlyType{}};
static_cast<void>(arr1);
[[maybe_unused]] constexpr wpi::array<MoveOnlyType, 3> arr1{
MoveOnlyType{}, MoveOnlyType{}, MoveOnlyType{}};
// Test deduction guide
constexpr wpi::array arr2{MoveOnlyType{}, MoveOnlyType{}, MoveOnlyType{}};
static_cast<void>(arr2);
[[maybe_unused]] constexpr wpi::array arr2{MoveOnlyType{}, MoveOnlyType{},
MoveOnlyType{}};
}