Skip to content

Commit

Permalink
avoid using namespace std to prevent future compat problems
Browse files Browse the repository at this point in the history
  • Loading branch information
exaexa committed Sep 25, 2022
1 parent 64585f2 commit 08e8bd6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
10 changes: 4 additions & 6 deletions src/hashfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
#include "hashfile.h"

#include <map>
using namespace std;

#include <stdint.h>
#include <cstdint>

#include "hash.h"
#include "iohelpers.h"
Expand Down Expand Up @@ -72,7 +70,7 @@ class size64proc : public hash_proc
* list of hash functions available
*/

typedef map<string, instanceof<hash_proc> > hashmap;
typedef std::map<std::string, instanceof<hash_proc> > hashmap;

void fill_hashmap (hashmap&t)
{
Expand All @@ -89,7 +87,7 @@ void fill_hashmap (hashmap&t)
t["SIZE64"] = new size64proc;
}

bool hashfile::create (istream&in)
bool hashfile::create (std::istream&in)
{
hashes.clear();

Expand Down Expand Up @@ -120,7 +118,7 @@ bool hashfile::create (istream&in)
}
}

int hashfile::verify (istream&in)
int hashfile::verify (std::istream&in)
{
hashmap hm_all, hm;
fill_hashmap (hm_all);
Expand Down
20 changes: 9 additions & 11 deletions src/mce_qcmdpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@

#include "mce_qcmdpc.h"

#include "fft.h"
#include <list>
#include <cmath>

#include "fft.h"

using namespace mce_qcmdpc;
using namespace std;

int mce_qcmdpc::generate (pubkey&pub, privkey&priv, prng&rng,
uint block_size, uint block_count, uint wi,
Expand All @@ -43,7 +44,7 @@ int mce_qcmdpc::generate (pubkey&pub, privkey&priv, prng&rng,
* (1+x^n).
*/

vector<dcx> H_last_inv;
std::vector<dcx> H_last_inv;

for (;;) {
//retry generating the rightmost block until it is invertible
Expand Down Expand Up @@ -100,7 +101,7 @@ int mce_qcmdpc::generate (pubkey&pub, privkey&priv, prng&rng,
priv.H[i] = Hb;

//compute inv(H[last])*H[i]
vector<dcx> H;
std::vector<dcx> H;
fft (Hb, H);
for (j = 0; j < block_size; ++j)
H[j] *= H_last_inv[j];
Expand Down Expand Up @@ -152,7 +153,7 @@ int pubkey::encrypt (const bvector&in, bvector&out, const bvector&errors)
if (G[i].size() != bs) return 1; //prevent mangled keys

//first, the checksum part
vector<dcx> bcheck, Pd, Gd;
std::vector<dcx> bcheck, Pd, Gd;
bcheck.resize (bs, dcx (0, 0)); //initially zero
bvector block;

Expand Down Expand Up @@ -189,9 +190,6 @@ int privkey::decrypt (const bvector & in, bvector & out)
return decrypt (in, out, tmp_errors);
}

#include <vector>
#include <list>

int privkey::decrypt (const bvector & in_orig, bvector & out, bvector & errors)
{
uint i, j;
Expand All @@ -208,7 +206,7 @@ int privkey::decrypt (const bvector & in_orig, bvector & out, bvector & errors)
* probabilistic decoding!
*/

vector<dcx> synd_diag, tmp, Htmp;
std::vector<dcx> synd_diag, tmp, Htmp;
synd_diag.resize (bs, dcx (0, 0));

//precompute the syndrome
Expand All @@ -225,7 +223,7 @@ int privkey::decrypt (const bvector & in_orig, bvector & out, bvector & errors)
fft (synd_diag, syndrome);

//precompute sparse matrix indexes
vector<list<uint> > Hsp;
std::vector<std::list<uint> > Hsp;
Hsp.resize (blocks);
for (i = 0; i < blocks; ++i)
for (j = 0; j < bs; ++j)
Expand All @@ -242,7 +240,7 @@ int privkey::decrypt (const bvector & in_orig, bvector & out, bvector & errors)
* FFT would be a cool candidate.
*/

vector<unsigned> unsat, round_unsat;
std::vector<unsigned> unsat, round_unsat;
unsat.resize (cs, 0);

for (uint blk = 0; blk < blocks; ++blk)
Expand Down
3 changes: 1 addition & 2 deletions src/str_match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include <algorithm>
#include <cctype> //for tolower()
using namespace std;

bool algorithm_name_matches (const std::string& search,
const std::string&name)
Expand All @@ -34,7 +33,7 @@ bool algorithm_name_matches (const std::string& search,
return true;
}

bool matches_icase (string name, string s)
bool matches_icase (std::string name, std::string s)
{
transform (name.begin(), name.end(), name.begin(), ::tolower);
transform (s.begin(), s.end(), s.begin(), ::tolower);
Expand Down

0 comments on commit 08e8bd6

Please sign in to comment.