Cleanup: Clang-Tidy, modernize-make-unique
This commit is contained in:
parent
ce70f2e1e0
commit
3cb4c51308
Notes:
blender-bot
2023-02-14 06:47:29 +01:00
Referenced by commit 6507449e54
, Cleanup: fix wrong merge, remove extra unique_ptr.
|
@ -45,7 +45,6 @@ Checks: >
|
|||
-modernize-loop-convert,
|
||||
-modernize-pass-by-value,
|
||||
-modernize-use-default-member-init,
|
||||
-modernize-make-unique,
|
||||
-modernize-raw-string-literal,
|
||||
-modernize-avoid-bind,
|
||||
-modernize-use-override,
|
||||
|
|
|
@ -519,7 +519,7 @@ class IMeshArena::IMeshArenaImpl : NonCopyable, NonMovable {
|
|||
|
||||
IMeshArena::IMeshArena()
|
||||
{
|
||||
pimpl_ = std::unique_ptr<IMeshArenaImpl>(new IMeshArenaImpl());
|
||||
pimpl_ = std::unique_ptr<IMeshArenaImpl>(std::make_unique<IMeshArenaImpl>());
|
||||
}
|
||||
|
||||
IMeshArena::~IMeshArena()
|
||||
|
|
|
@ -419,9 +419,9 @@ TEST(map, Clear)
|
|||
|
||||
TEST(map, UniquePtrValue)
|
||||
{
|
||||
auto value1 = std::unique_ptr<int>(new int());
|
||||
auto value2 = std::unique_ptr<int>(new int());
|
||||
auto value3 = std::unique_ptr<int>(new int());
|
||||
auto value1 = std::unique_ptr<int>(std::make_unique<int>());
|
||||
auto value2 = std::unique_ptr<int>(std::make_unique<int>());
|
||||
auto value3 = std::unique_ptr<int>(std::make_unique<int>());
|
||||
|
||||
int *value1_ptr = value1.get();
|
||||
|
||||
|
@ -429,12 +429,12 @@ TEST(map, UniquePtrValue)
|
|||
map.add_new(1, std::move(value1));
|
||||
map.add(2, std::move(value2));
|
||||
map.add_overwrite(3, std::move(value3));
|
||||
map.lookup_or_add_cb(4, []() { return std::unique_ptr<int>(new int()); });
|
||||
map.add_new(5, std::unique_ptr<int>(new int()));
|
||||
map.add(6, std::unique_ptr<int>(new int()));
|
||||
map.add_overwrite(7, std::unique_ptr<int>(new int()));
|
||||
map.lookup_or_add(8, std::unique_ptr<int>(new int()));
|
||||
map.pop_default(9, std::unique_ptr<int>(new int()));
|
||||
map.lookup_or_add_cb(4, []() { return std::unique_ptr<int>(std::make_unique<int>()); });
|
||||
map.add_new(5, std::unique_ptr<int>(std::make_unique<int>()));
|
||||
map.add(6, std::unique_ptr<int>(std::make_unique<int>()));
|
||||
map.add_overwrite(7, std::unique_ptr<int>(std::make_unique<int>()));
|
||||
map.lookup_or_add(8, std::unique_ptr<int>(std::make_unique<int>()));
|
||||
map.pop_default(9, std::unique_ptr<int>(std::make_unique<int>()));
|
||||
|
||||
EXPECT_EQ(map.lookup(1).get(), value1_ptr);
|
||||
EXPECT_EQ(map.lookup_ptr(100), nullptr);
|
||||
|
|
|
@ -221,10 +221,10 @@ TEST(set, OftenAddRemoveContained)
|
|||
TEST(set, UniquePtrValues)
|
||||
{
|
||||
Set<std::unique_ptr<int>> set;
|
||||
set.add_new(std::unique_ptr<int>(new int()));
|
||||
auto value1 = std::unique_ptr<int>(new int());
|
||||
set.add_new(std::unique_ptr<int>(std::make_unique<int>()));
|
||||
auto value1 = std::unique_ptr<int>(std::make_unique<int>());
|
||||
set.add_new(std::move(value1));
|
||||
set.add(std::unique_ptr<int>(new int()));
|
||||
set.add(std::unique_ptr<int>(std::make_unique<int>()));
|
||||
|
||||
EXPECT_EQ(set.size(), 3);
|
||||
}
|
||||
|
|
|
@ -170,8 +170,8 @@ TEST(stack, Peek)
|
|||
TEST(stack, UniquePtrValues)
|
||||
{
|
||||
Stack<std::unique_ptr<int>> stack;
|
||||
stack.push(std::unique_ptr<int>(new int()));
|
||||
stack.push(std::unique_ptr<int>(new int()));
|
||||
stack.push(std::unique_ptr<int>(std::make_unique<int>()));
|
||||
stack.push(std::unique_ptr<int>(std::make_unique<int>()));
|
||||
std::unique_ptr<int> a = stack.pop();
|
||||
std::unique_ptr<int> &b = stack.peek();
|
||||
UNUSED_VARS(a, b);
|
||||
|
|
|
@ -142,9 +142,9 @@ TEST(vector_set, AddMultipleTimes)
|
|||
TEST(vector_set, UniquePtrValue)
|
||||
{
|
||||
VectorSet<std::unique_ptr<int>> set;
|
||||
set.add_new(std::unique_ptr<int>(new int()));
|
||||
set.add(std::unique_ptr<int>(new int()));
|
||||
set.index_of_try(std::unique_ptr<int>(new int()));
|
||||
set.add_new(std::unique_ptr<int>(std::make_unique<int>()));
|
||||
set.add(std::unique_ptr<int>(std::make_unique<int>()));
|
||||
set.index_of_try(std::unique_ptr<int>(std::make_unique<int>()));
|
||||
std::unique_ptr<int> value = set.pop();
|
||||
UNUSED_VARS(value);
|
||||
}
|
||||
|
|
|
@ -456,10 +456,10 @@ TEST(vector, AppendNTimes)
|
|||
TEST(vector, UniquePtrValue)
|
||||
{
|
||||
Vector<std::unique_ptr<int>> vec;
|
||||
vec.append(std::unique_ptr<int>(new int()));
|
||||
vec.append(std::unique_ptr<int>(new int()));
|
||||
vec.append(std::unique_ptr<int>(new int()));
|
||||
vec.append(std::unique_ptr<int>(new int()));
|
||||
vec.append(std::unique_ptr<int>(std::make_unique<int>()));
|
||||
vec.append(std::unique_ptr<int>(std::make_unique<int>()));
|
||||
vec.append(std::unique_ptr<int>(std::make_unique<int>()));
|
||||
vec.append(std::unique_ptr<int>(std::make_unique<int>()));
|
||||
EXPECT_EQ(vec.size(), 4);
|
||||
|
||||
std::unique_ptr<int> &a = vec.last();
|
||||
|
|
|
@ -27,6 +27,8 @@ namespace Freestyle {
|
|||
|
||||
template<typename T> class AutoPtr : public std::unique_ptr<T> {
|
||||
public:
|
||||
using std::unique_ptr<T>::unique_ptr;
|
||||
|
||||
AutoPtr() : std::unique_ptr<T>()
|
||||
{
|
||||
}
|
||||
|
@ -42,6 +44,8 @@ template<typename T> class AutoPtr : public std::unique_ptr<T> {
|
|||
other.release();
|
||||
}
|
||||
|
||||
using std::unique_ptr<T>::operator=;
|
||||
|
||||
template<typename X> AutoPtr &operator=(AutoPtr<X> &other) = delete;
|
||||
};
|
||||
|
||||
|
|
|
@ -1381,17 +1381,17 @@ void ViewMapBuilder::ComputeCumulativeVisibility(ViewMap *ioViewMap,
|
|||
AutoPtr<OccluderSource> source;
|
||||
|
||||
if (_orthographicProjection) {
|
||||
transform.reset(new BoxGrid::Transform);
|
||||
transform = std::make_unique<BoxGrid::Transform>();
|
||||
}
|
||||
else {
|
||||
transform.reset(new SphericalGrid::Transform);
|
||||
transform = std::make_unique<SphericalGrid::Transform>();
|
||||
}
|
||||
|
||||
if (cull) {
|
||||
source.reset(new CulledOccluderSource(*transform, we, *ioViewMap, true));
|
||||
source = std::make_unique<CulledOccluderSource>(*transform, we, *ioViewMap, true);
|
||||
}
|
||||
else {
|
||||
source.reset(new OccluderSource(*transform, we));
|
||||
source = std::make_unique<OccluderSource>(*transform, we);
|
||||
}
|
||||
|
||||
AutoPtr<GridDensityProvider> density(factory.newGridDensityProvider(*source, bbox, *transform));
|
||||
|
@ -1419,17 +1419,17 @@ void ViewMapBuilder::ComputeDetailedVisibility(ViewMap *ioViewMap,
|
|||
AutoPtr<OccluderSource> source;
|
||||
|
||||
if (_orthographicProjection) {
|
||||
transform.reset(new BoxGrid::Transform);
|
||||
transform = std::make_unique<BoxGrid::Transform>();
|
||||
}
|
||||
else {
|
||||
transform.reset(new SphericalGrid::Transform);
|
||||
transform = std::make_unique<SphericalGrid::Transform>();
|
||||
}
|
||||
|
||||
if (cull) {
|
||||
source.reset(new CulledOccluderSource(*transform, we, *ioViewMap, true));
|
||||
source = std::make_unique<CulledOccluderSource>(*transform, we, *ioViewMap, true);
|
||||
}
|
||||
else {
|
||||
source.reset(new OccluderSource(*transform, we));
|
||||
source = std::make_unique<OccluderSource>(*transform, we);
|
||||
}
|
||||
|
||||
AutoPtr<GridDensityProvider> density(factory.newGridDensityProvider(*source, bbox, *transform));
|
||||
|
|
Loading…
Reference in New Issue