From 85e2c1b4ecbaf975d9d978f01227dc4987ee9d6c Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 30 Apr 2019 11:36:18 +0200 Subject: apt-pkg: hashes: Add 'explicit' to single argument constructors This avoids funny code where strings get implicitly converted to HashString or HashStringList. --- apt-pkg/contrib/hashes.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h index 9ef2945d7..c636852ec 100644 --- a/apt-pkg/contrib/hashes.h +++ b/apt-pkg/contrib/hashes.h @@ -47,7 +47,7 @@ class HashString public: HashString(std::string Type, std::string Hash); - HashString(std::string StringedHashString); // init from str as "type:hash" + explicit HashString(std::string StringedHashString); // init from str as "type:hash" HashString(); // get hash type used @@ -163,11 +163,11 @@ class HashStringList HashStringList() {} // simplifying API-compatibility constructors - HashStringList(std::string const &hash) { + explicit HashStringList(std::string const &hash) { if (hash.empty() == false) list.push_back(HashString(hash)); } - HashStringList(char const * const hash) { + explicit HashStringList(char const * const hash) { if (hash != NULL && hash[0] != '\0') list.push_back(HashString(hash)); } @@ -210,9 +210,9 @@ class Hashes * which hashes to generate. */ Hashes(); /** @param Hashes bitflag composed of #SupportedHashes */ - Hashes(unsigned int const Hashes); + explicit Hashes(unsigned int const Hashes); /** @param Hashes is a list of hashes */ - Hashes(HashStringList const &Hashes); + explicit Hashes(HashStringList const &Hashes); virtual ~Hashes(); }; -- cgit v1.2.3