Skip to content

Commit

Permalink
Remove using namespace std and add std:: qualifications where needed (#…
Browse files Browse the repository at this point in the history
…2092)

`using namespace std;` is generally an antipattern as it imports a huge
number of common names into the global namespace. We already qualify
names with std:: in majority of cases and `using namespace std` is not
actually needed most of the time. This commit addresses a small number
of remaining cases where std:: is missing and removes all `using
namespace std`.
  • Loading branch information
p12tic committed Jul 11, 2022
1 parent aede84b commit 08ac774
Show file tree
Hide file tree
Showing 62 changed files with 104 additions and 173 deletions.
1 change: 0 additions & 1 deletion src/openMVG/exif/exif_IO_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <iostream>
#include <memory>

using namespace std;
using namespace openMVG;
using namespace openMVG::exif;

Expand Down
3 changes: 0 additions & 3 deletions src/openMVG/features/features_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@

using namespace openMVG;
using namespace openMVG::features;
using namespace std;

using std::string;

// Define a feature and a container of features
using Feature_T = SIOPointFeature;
Expand Down
3 changes: 0 additions & 3 deletions src/openMVG/features/image_describer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@

using namespace openMVG;
using namespace openMVG::features;
using namespace std;

using std::string;

bool SaveAndLoad
(
Expand Down
1 change: 0 additions & 1 deletion src/openMVG/geometry/frustum_box_intersection_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
using namespace openMVG;
using namespace openMVG::geometry;
using namespace openMVG::geometry::halfPlane;
using namespace std;

//--
// Box/Camera frustum intersection unit test
Expand Down
1 change: 0 additions & 1 deletion src/openMVG/geometry/frustum_intersection_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
using namespace openMVG;
using namespace openMVG::geometry;
using namespace openMVG::geometry::halfPlane;
using namespace std;

//--
// Camera frustum intersection unit test
Expand Down
1 change: 0 additions & 1 deletion src/openMVG/geometry/half_space_intersection_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

using namespace openMVG;
using namespace openMVG::geometry::halfPlane;
using namespace std;

TEST(HALF_PLANE, ExistingSubspace) {

Expand Down
1 change: 0 additions & 1 deletion src/openMVG/geometry/rigid_transformation3D_srt_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

using namespace openMVG;
using namespace openMVG::geometry;
using namespace std;

TEST(SRT_precision, Experiment_ScaleOnly) {

Expand Down
1 change: 0 additions & 1 deletion src/openMVG/image/image_filtering_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

using namespace openMVG;
using namespace openMVG::image;
using namespace std;

TEST(Image, Convolution)
{
Expand Down
7 changes: 3 additions & 4 deletions src/openMVG/image/image_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include <iostream>

using namespace std;
using namespace openMVG;
using namespace openMVG::image;

Expand All @@ -26,12 +25,12 @@ TEST(Image, Basis)
imaGray(2,2) = 2;
imaGray(5,0) = 2;

cout << imaGray << endl << endl;
std::cout << imaGray << std::endl << std::endl;
//-- Get raw ptr to image data :
const unsigned char * ptr = imaGray.data();
((unsigned char*)ptr)[0] = 2;
fill(((unsigned char*)ptr+9*10),((unsigned char*)ptr+10*10),2);
cout << "After" << endl << imaGray;
std::fill(((unsigned char*)ptr+9*10),((unsigned char*)ptr+10*10),2);
std::cout << "After" << std::endl << imaGray;

// Construction by re-copy
Image<unsigned char> imageGray2(imaGray);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using namespace openMVG;
using namespace openMVG::linearProgramming;
using namespace lInfinityCV;
using namespace std;

TEST(translation_averaging, globalTi_from_tijs) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using namespace openMVG;
using namespace openMVG::linearProgramming;
using namespace lInfinityCV;
using namespace std;

TEST(translation_averaging, globalTi_from_tijs_Triplets) {

Expand Down
7 changes: 3 additions & 4 deletions src/openMVG/matching/matching_filters_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@

using namespace openMVG;
using namespace openMVG::matching;
using namespace std;

/// Sorted vector intersection (increasing order)
TEST( matching, setIntersection)
{
const int tab0[] = {0, 1, 2, 3, 4, 5, 6, 7};
const int tab1[] = {0, 1, 8, 3, 4, 9, 6, 7};
const set<int> vec_0(tab0, tab0+8);
const set<int> vec_1(tab1, tab1+8);
const std::set<int> vec_0(tab0, tab0+8);
const std::set<int> vec_1(tab1, tab1+8);
/// Array must be sorted

vector<int> vec_intersect;
std::vector<int> vec_intersect;
IntersectMatches(vec_0.begin(), vec_0.end(),
vec_1.begin(), vec_1.end(),
vec_intersect);
Expand Down
7 changes: 3 additions & 4 deletions src/openMVG/matching/matching_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "testing/testing.h"

#include <iostream>
using namespace std;

using namespace openMVG;
using namespace matching;
Expand Down Expand Up @@ -48,7 +47,7 @@ TEST(Matching, ArrayMatcherBruteForce_NN)

const float query[] = {2};
IndMatches vec_nIndice;
vector<float> vec_fDistance;
std::vector<float> vec_fDistance;
EXPECT_TRUE( matcher.SearchNeighbours(query,1, &vec_nIndice, &vec_fDistance, 5) );

EXPECT_EQ( 5, vec_nIndice.size());
Expand Down Expand Up @@ -97,7 +96,7 @@ TEST(Matching, ArrayMatcher_Kdtree_Flann_Simple__NN)

const float query[] = {2};
IndMatches vec_nIndice;
vector<float> vec_fDistance;
std::vector<float> vec_fDistance;
const int NN = 5;
EXPECT_TRUE( matcher.SearchNeighbours(query, 1, &vec_nIndice, &vec_fDistance, NN) );

Expand Down Expand Up @@ -129,7 +128,7 @@ TEST(Matching, ArrayMatcher_Hnsw_Simple__NN)

const float query[] = {2};
IndMatches vec_nIndice;
vector<float> vec_fDistance;
std::vector<float> vec_fDistance;
const int NN = 5;
EXPECT_TRUE( matcher.SearchNeighbours(query, 1, &vec_nIndice, &vec_fDistance, NN) );

Expand Down
2 changes: 0 additions & 2 deletions src/openMVG/matching/metric_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

#include <iostream>

using namespace std;

using namespace openMVG;
using namespace matching;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <iostream>

using namespace openMVG;
using namespace std;

// Check pairs follow a weak ordering pair.first < pair.second
template<typename IterablePairs>
Expand Down
4 changes: 0 additions & 4 deletions src/openMVG/multiview/rotation_averaging_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ TEST ( rotation_averaging, ClosestSVDRotationMatrixNoisy )
// 1
TEST ( rotation_averaging, RotationLeastSquare_3_Camera)
{
using namespace std;

//--
// Setup 3 camera that have a relative orientation of 120 degree
// Set Z axis as UP Vector for the rotation
Expand Down Expand Up @@ -162,8 +160,6 @@ TEST ( rotation_averaging, RefineRotationsL2_CompleteGraph)

TEST ( rotation_averaging, RefineRotationsAvgL1IRLS_SimpleTriplet)
{
using namespace std;

//--
// Setup 3 camera that have a relative orientation of 120 degree
// Set Z axis as UP Vector for the rotation
Expand Down
5 changes: 2 additions & 3 deletions src/openMVG/multiview/solver_fundamental_kernel_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include <numeric>

using namespace openMVG;
using namespace std;

// Check that sin(angle(a, b)) < tolerance.
template<typename A, typename B>
Expand Down Expand Up @@ -86,9 +85,9 @@ bool ExpectKernelProperties(const Mat &x1,
Mat3 *F_expected = nullptr) {
bool bOk = true;
Kernel kernel(x1, x2);
vector<uint32_t> samples(x1.cols());
std::vector<uint32_t> samples(x1.cols());
std::iota(samples.begin(), samples.end(), 0);
vector<Mat3> Fs;
std::vector<Mat3> Fs;
kernel.Fit(samples, &Fs);

bOk &= (!Fs.empty());
Expand Down
13 changes: 6 additions & 7 deletions src/openMVG/multiview/solver_homography_kernel_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@

#include <vector>

using namespace std;
using namespace openMVG;

TEST(HomographyKernelTest, Fitting_Unnormalized) {
// Define 3 knows homographies (Use as GT).
vector<Mat3> H_gt(3);
std::vector<Mat3> H_gt(3);

H_gt[0] = Mat3::Identity();
H_gt[1] << 1, 0, -4, // Affine homography motion
Expand All @@ -60,13 +59,13 @@ TEST(HomographyKernelTest, Fitting_Unnormalized) {

homography::kernel::UnnormalizedKernel kernel(x, y);

vector<uint32_t> samples = {0,1,2,3,4};
std::vector<uint32_t> samples = {0,1,2,3,4};
for (
Mat::Index j = 4;
static_cast<Mat::Index>(samples.size()) < x.cols();
samples.push_back(j++))
{
vector<Mat3> Hs;
std::vector<Mat3> Hs;
kernel.Fit(samples, &Hs);
CHECK_EQUAL(1, Hs.size());
// Check that found matrix is equal to the GT
Expand All @@ -77,7 +76,7 @@ TEST(HomographyKernelTest, Fitting_Unnormalized) {

TEST(HomographyKernelTest, Fitting_Normalized) {
// Define 3 knows homographies (Use as GT).
vector<Mat3> H_gt(3);
std::vector<Mat3> H_gt(3);

H_gt[0] = Mat3::Identity();
H_gt[1] << 1, 0, -4, // Affine homography motion
Expand All @@ -99,13 +98,13 @@ TEST(HomographyKernelTest, Fitting_Normalized) {

homography::kernel::Kernel kernel(x, y);

vector<uint32_t> samples = {0,1,2,3,4};
std::vector<uint32_t> samples = {0,1,2,3,4};
for (
Mat::Index j = 4;
static_cast<Mat::Index>(samples.size()) < x.cols();
samples.push_back(j++))
{
vector<Mat3> Hs;
std::vector<Mat3> Hs;
kernel.Fit(samples, &Hs);
CHECK_EQUAL(1, Hs.size());
// Check that found matrix is equal to the GT
Expand Down
4 changes: 1 addition & 3 deletions src/openMVG/multiview/solver_resection_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ namespace openMVG {
namespace resection {
namespace kernel {

using namespace std;

void translate
(
const Mat3X & X,
Expand Down Expand Up @@ -71,7 +69,7 @@ void SixPointResectionSolver::Solve
(
const Mat &pt2D,
const Mat &pt3d,
vector<Mat34> *Ps,
std::vector<Mat34> *Ps,
bool bcheck
)
{
Expand Down
1 change: 0 additions & 1 deletion src/openMVG/multiview/translation_averaging_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include <vector>

using namespace openMVG;
using namespace std;

TEST(translation_averaging, globalTi_from_tijs_Triplets_softL1_Ceres) {

Expand Down
1 change: 0 additions & 1 deletion src/openMVG/multiview/triangulation_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "testing/testing.h"

using namespace openMVG;
using namespace std;

TEST(Triangulation, TriangulateDLT) {

Expand Down
1 change: 0 additions & 1 deletion src/openMVG/numeric/l1_solver_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <random>

using namespace openMVG;
using namespace std;

TEST(L1Solver_ADMM, Decoding)
{
Expand Down
1 change: 0 additions & 1 deletion src/openMVG/numeric/lm_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

using namespace openMVG;
using namespace svg;
using namespace std;

// Implementation of the problem found here:
// digilander.libero.it/foxes/optimiz/Optimiz1.htm
Expand Down
1 change: 0 additions & 1 deletion src/openMVG/numeric/numeric_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include <set>

using namespace openMVG;
using namespace std;

//-- Assert that stream interface is available
TEST ( TinyMatrix, print )
Expand Down
1 change: 0 additions & 1 deletion src/openMVG/robust_estimation/gms_filter_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

using namespace openMVG;
using namespace openMVG::robust;
using namespace std;

TEST(GMSFilter, borderCases)
{
Expand Down

0 comments on commit 08ac774

Please sign in to comment.