Skip to content
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 ETL_TYPEDEF Trivially Copyable #1000

Open
drewr95 opened this issue Dec 24, 2024 · 3 comments
Open

Make ETL_TYPEDEF Trivially Copyable #1000

drewr95 opened this issue Dec 24, 2024 · 3 comments

Comments

@drewr95
Copy link
Contributor

drewr95 commented Dec 24, 2024

I'm getting a clang-tidy warning when passing around an ETL_TYPEDEF(degrees, float) by copy to pass it as const reference. Doing some research, clang-tidy weighs the check with whether the type is trivially copyable. I think the way the strong types are generated, there is no need to define the copy ctor or assignment operator.

@drewr95
Copy link
Contributor Author

drewr95 commented Dec 24, 2024

I see BOOST's strong typedefs are very similar and also not trivially copyable. Is there a reason why? With the way it's implemented I'm not sure why it would need to be defined? Would it be for if the underlying type wasn't trivially copyable?

@jwellbelove
Copy link
Contributor

I've tried a few experiments, with both trivially and non-trivially copyable types, with the default constructor, copy constructor, and assignment operator removed or defaulted, and everything appears to work as expected.

ETL_TYPEDEF(uint32_t, type1_t);
ETL_TYPEDEF(std::vector<uint32_t>, type2_t);

bool b1 = std::is_trivially_copyable_v<type1_t>; // true
bool b2 = std::is_trivially_copyable_v<type2_t>; // false

@drewr95
Copy link
Contributor Author

drewr95 commented Dec 27, 2024

I've tried a few experiments, with both trivially and non-trivially copyable types, with the default constructor, copy constructor, and assignment operator removed or defaulted, and everything appears to work as expected.

ETL_TYPEDEF(uint32_t, type1_t); ETL_TYPEDEF(std::vector<uint32_t>, type2_t);

bool b1 = std::is_trivially_copyable_v<type1_t>; // true bool b2 = std::is_trivially_copyable_v<type2_t>; // false

That is awesome news! I'm hoping to have something in within a couple days if you don't beat me to it :)

I'd also aim for the move ctor and assignment to be defaulted as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants