warns to use 'auto' to avoid repeating the type name and fixes the issue
std::unique_ptr<Foo> x = make_unique<Foo>(...);
auto x = make_unique<Foo>(...);
hugoeg on Aug 16 2018, 10:30 AM.Authored by
since this check checks for absl::make_unique primarily
Why do you think it would be weird?
Just checking, was there some memo i missed that abseil-related checks are exempt from all the usual guidelines?
I checked fast and modernize-use-auto does not catch this case.
Because this check is really not abseil-library-specific.
I agree that this check is general for make_... templates. It should be either an addition to modernize-use-auto or readability- or so. What we do for such cases, where the check is generally useful and specific to a guideline at the same time is aliasing.
You can take a look at hicpp- module where most checks are actually aliases.
First of all, thanks, Hugo, for your check!
My +1 for extending modernize-use-auto as currently it doesn't support cases your check supports.
std::unique_ptr< int >y = std::make_unique<int>();
auto y = std::make_unique<int>();
is logically the same as replacing
long long int *y = new long long int (42);
auto* y = new long long int (42);
what modernize-use-auto does.
So your check should extend the existing one and not create one more check IMHO.