-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make not_null<foo*> trivially copyable. #3304
Conversation
This fixes an annoying -Wrange-loop-construct clang warning.
Lint errors:
|
base/not_null_test.cpp
Outdated
@@ -262,5 +268,25 @@ TEST_F(NotNullTest, RValue) { | |||
EXPECT_EQ(5, *owner_const_int); | |||
} | |||
|
|||
TEST_F(NotNullTest, TypeTraits) { | |||
// not_null<foo*> is trivially copyable. | |||
EXPECT_TRUE(std::is_trivially_copyable_v<not_null<int*>>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change all of those to static_assert
(cf. https://github.com/mockingbirdnest/Principia/blob/master/numerics/next_test.cpp which tests constexpr code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
The linter is still unhappy (and somewhat dumb):
|
This fixes an annoying -Wrange-loop-construct clang warning.
Done by creating a wrapper struct that uses the default move assignment operator for trivially move assignable pointers and the custom swap-based move assignment operator for others.