Skip to content

Commit

Permalink
STYLE: Replace (const std::string) casts with C++17 std::string_view
Browse files Browse the repository at this point in the history
Prevented potential static analysis warnings, like Clang-Tidy:

> C-style casts are discouraged; use static_cast [google-readability-casting]

And JetBrains ReSharper:

> C-style cast is used instead of a C++ cast

Note that `std::string_view` is more lightweight than `std::string`.
  • Loading branch information
N-Dekker authored and hjmjohnson committed Apr 16, 2024
1 parent 2082a93 commit 2a1265d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ itkQuadEdgeMeshEulerOperatorDeleteCenterVertexTest(int argc, char * argv[])
}
std::cout << "OK" << std::endl;

ITK_TEST_EXPECT_EQUAL((const std::string) "QuadEdgeMeshEulerOperatorDeleteCenterVertexFunction",
(const std::string)deleteCenterVertex->GetNameOfClass());
ITK_TEST_EXPECT_EQUAL(std::string_view("QuadEdgeMeshEulerOperatorDeleteCenterVertexFunction"),
std::string_view(deleteCenterVertex->GetNameOfClass()));

deleteCenterVertex->SetInput(mesh);
std::cout << " "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ itkQuadEdgeMeshEulerOperatorJoinFacetTest(int, char *[])
std::cout << "OK" << std::endl;
#endif

ITK_TEST_EXPECT_EQUAL((const std::string) "QuadEdgeMeshEulerOperatorJoinFacetFunction",
(const std::string)joinFacet->GetNameOfClass());
ITK_TEST_EXPECT_EQUAL(std::string_view("QuadEdgeMeshEulerOperatorJoinFacetFunction"),
std::string_view(joinFacet->GetNameOfClass()));

joinFacet->SetInput(mesh);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ itkQuadEdgeMeshEulerOperatorJoinVertexTest(int argc, char * argv[])
std::cout << "OK" << std::endl;
#endif

ITK_TEST_EXPECT_EQUAL((const std::string) "QuadEdgeMeshEulerOperatorJoinVertexFunction",
(const std::string)joinVertex->GetNameOfClass());
ITK_TEST_EXPECT_EQUAL(std::string_view("QuadEdgeMeshEulerOperatorJoinVertexFunction"),
std::string_view(joinVertex->GetNameOfClass()));

joinVertex->SetInput(mesh);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ itkQuadEdgeMeshEulerOperatorSplitEdgeTest(int, char *[])
}
std::cout << "OK" << std::endl;

ITK_TEST_EXPECT_EQUAL((const std::string) "QuadEdgeMeshEulerOperatorSplitEdgeFunction",
(const std::string)splitEdge->GetNameOfClass());
ITK_TEST_EXPECT_EQUAL(std::string_view("QuadEdgeMeshEulerOperatorSplitEdgeFunction"),
std::string_view(splitEdge->GetNameOfClass()));

splitEdge->SetInput(mesh);
std::cout << " "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ itkQuadEdgeMeshEulerOperatorSplitVertexTest(int, char *[])
}
std::cout << "OK" << std::endl;

ITK_TEST_EXPECT_EQUAL((const std::string) "QuadEdgeMeshEulerOperatorSplitVertexFunction",
(const std::string)splitVertex->GetNameOfClass());
ITK_TEST_EXPECT_EQUAL(std::string_view("QuadEdgeMeshEulerOperatorSplitVertexFunction"),
std::string_view(splitVertex->GetNameOfClass()));

splitVertex->SetInput(mesh);
std::cout << " "
Expand Down

0 comments on commit 2a1265d

Please sign in to comment.