From 75c88468a79a270964dd8d11a1f0846467307bd2 Mon Sep 17 00:00:00 2001
From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz>
Date: Thu, 15 May 2014 20:04:33 +0200
Subject: [PATCH] explicit constructors

---
 alib2/src/AlibException.h                | 2 +-
 alib2/src/alphabet/Blank.cpp             | 2 ++
 alib2/src/alphabet/Blank.h               | 1 +
 alib2/src/alphabet/Symbol.h              | 4 ++--
 alib2/src/automaton/AutomatonException.h | 2 +-
 alib2/src/automaton/UnknownAutomaton.cpp | 5 +++--
 alib2/src/regexp/Alternation.h           | 4 ++--
 alib2/src/regexp/Concatenation.h         | 4 ++--
 alib2/src/regexp/Iteration.h             | 4 ++--
 alib2/src/regexp/RegExp.h                | 4 ++--
 alib2/src/regexp/RegExpSymbol.h          | 4 ++--
 alib2/src/string/CyclicString.h          | 2 +-
 alib2/src/string/String.h                | 2 +-
 13 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/alib2/src/AlibException.h b/alib2/src/AlibException.h
index 7a8c7e082c..9c33fd60cb 100644
--- a/alib2/src/AlibException.h
+++ b/alib2/src/AlibException.h
@@ -24,7 +24,7 @@ protected:
 public:
 
 	AlibException ( );
-	AlibException ( const std::string & cause );
+	explicit AlibException ( const std::string & cause );
 	virtual ~AlibException ( ) noexcept;
 
 	/**
diff --git a/alib2/src/alphabet/Blank.cpp b/alib2/src/alphabet/Blank.cpp
index 0f604e22d8..060950e349 100644
--- a/alib2/src/alphabet/Blank.cpp
+++ b/alib2/src/alphabet/Blank.cpp
@@ -13,4 +13,6 @@ Blank::Blank() : Symbol("") {
 
 }
 
+Blank Blank::BLANK = Blank();
+
 } /* namespace alphabet */
diff --git a/alib2/src/alphabet/Blank.h b/alib2/src/alphabet/Blank.h
index b65c10fa74..f7a9708153 100644
--- a/alib2/src/alphabet/Blank.h
+++ b/alib2/src/alphabet/Blank.h
@@ -23,6 +23,7 @@ public:
 	 */
 	Blank();
 
+	static Blank BLANK;
 };
 
 } /* namespace alphabet */
diff --git a/alib2/src/alphabet/Symbol.h b/alib2/src/alphabet/Symbol.h
index 41b44a0dcb..a7c39ba3b3 100644
--- a/alib2/src/alphabet/Symbol.h
+++ b/alib2/src/alphabet/Symbol.h
@@ -24,8 +24,8 @@ public:
 	 * Creates new symbol with given name.
 	 * @param symbol name of the symbol
 	 */
-	Symbol(const std::string& symbol);
-	Symbol(std::string&& symbol);
+	explicit Symbol(const std::string& symbol);
+	explicit Symbol(std::string&& symbol);
 
 	/**
 	 * @return name of the symbol
diff --git a/alib2/src/automaton/AutomatonException.h b/alib2/src/automaton/AutomatonException.h
index 80f0662321..864312c09c 100644
--- a/alib2/src/automaton/AutomatonException.h
+++ b/alib2/src/automaton/AutomatonException.h
@@ -18,7 +18,7 @@ namespace automaton {
 class AutomatonException: public alib::AlibException {
 public:
 	AutomatonException();
-	AutomatonException(const std::string& cause);
+	explicit AutomatonException(const std::string& cause);
 	virtual ~AutomatonException() throw ();
 };
 
diff --git a/alib2/src/automaton/UnknownAutomaton.cpp b/alib2/src/automaton/UnknownAutomaton.cpp
index 9a3d7787d5..d8f79988a8 100644
--- a/alib2/src/automaton/UnknownAutomaton.cpp
+++ b/alib2/src/automaton/UnknownAutomaton.cpp
@@ -165,8 +165,9 @@ std::ostream& operator<<(std::ostream& out, const UnknownAutomaton& automaton) {
 		<< " stackAlphabet = " << automaton.stackAlphabet
 		<< " initialSymbols = " << automaton.initialSymbols
 		<< " tapeAlphabet = " << automaton.tapeAlphabet
-		<< " blankSymbol = " << ((automaton.blankSymbol == NULL) ? (std::string) "NULL" : *automaton.blankSymbol)
-		<< " transitions = " << automaton.transitions
+		<< " blankSymbol = ";
+	if(automaton.blankSymbol == NULL) out << "NULL"; else out << *automaton.blankSymbol;
+	out << " transitions = " << automaton.transitions
 		<< ")";
 	return out;
 }
diff --git a/alib2/src/regexp/Alternation.h b/alib2/src/regexp/Alternation.h
index 5424fe016e..8d6b1498c2 100644
--- a/alib2/src/regexp/Alternation.h
+++ b/alib2/src/regexp/Alternation.h
@@ -47,8 +47,8 @@ protected:
 	virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const;
 	
 public:
-	Alternation(RegExpElement&& left, RegExpElement&& right);
-	Alternation(const RegExpElement& left, const RegExpElement& right);
+	explicit Alternation(RegExpElement&& left, RegExpElement&& right);
+	explicit Alternation(const RegExpElement& left, const RegExpElement& right);
 	
 	Alternation(const Alternation& other);
 	Alternation(Alternation&& other) noexcept;
diff --git a/alib2/src/regexp/Concatenation.h b/alib2/src/regexp/Concatenation.h
index f3cb0ad367..de3430d129 100644
--- a/alib2/src/regexp/Concatenation.h
+++ b/alib2/src/regexp/Concatenation.h
@@ -44,8 +44,8 @@ protected:
 	virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const;
 
 public:
-	Concatenation(RegExpElement&& left, RegExpElement&& right);
-	Concatenation(const RegExpElement& left, const RegExpElement& right);
+	explicit Concatenation(RegExpElement&& left, RegExpElement&& right);
+	explicit Concatenation(const RegExpElement& left, const RegExpElement& right);
 	
 	Concatenation(const Concatenation& other);
 	Concatenation(Concatenation&& other) noexcept;
diff --git a/alib2/src/regexp/Iteration.h b/alib2/src/regexp/Iteration.h
index f0eb5139e0..18d226158c 100644
--- a/alib2/src/regexp/Iteration.h
+++ b/alib2/src/regexp/Iteration.h
@@ -44,8 +44,8 @@ protected:
 	virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const;
 	
 public:
-	Iteration(RegExpElement&&);
-	Iteration(const RegExpElement&);
+	explicit Iteration(RegExpElement&&);
+	explicit Iteration(const RegExpElement&);
 	
 	Iteration(const Iteration& other);
 	Iteration(Iteration&& other) noexcept;
diff --git a/alib2/src/regexp/RegExp.h b/alib2/src/regexp/RegExp.h
index 11a50be843..99b900f099 100644
--- a/alib2/src/regexp/RegExp.h
+++ b/alib2/src/regexp/RegExp.h
@@ -33,8 +33,8 @@ public:
 	RegExp();
 	RegExp(const std::set<alphabet::Symbol>& alphabet, const RegExpElement& regExp);
 	RegExp(std::set<alphabet::Symbol>&& alphabet, RegExpElement&& regExp);
-	RegExp(const RegExpElement& regExp);
-	RegExp(RegExpElement&& regExp);
+	explicit RegExp(const RegExpElement& regExp);
+	explicit RegExp(RegExpElement&& regExp);
 
 	/**
 	 * Copy constructor.
diff --git a/alib2/src/regexp/RegExpSymbol.h b/alib2/src/regexp/RegExpSymbol.h
index e94d40bc9b..c32dea2405 100644
--- a/alib2/src/regexp/RegExpSymbol.h
+++ b/alib2/src/regexp/RegExpSymbol.h
@@ -41,8 +41,8 @@ protected:
 	 */
 	virtual void computeMinimalAlphabet( std::set<alphabet::Symbol>& alphabet ) const;
 public:
-	RegExpSymbol(const std::string& symbol);
-	RegExpSymbol(std::string&& symbol);
+	explicit RegExpSymbol(const std::string& symbol);
+	explicit RegExpSymbol(std::string&& symbol);
 	
 	RegExpSymbol(const RegExpSymbol& other);
 	RegExpSymbol(RegExpSymbol&& other) noexcept;
diff --git a/alib2/src/string/CyclicString.h b/alib2/src/string/CyclicString.h
index 2db7f39cdc..79a65d9a33 100644
--- a/alib2/src/string/CyclicString.h
+++ b/alib2/src/string/CyclicString.h
@@ -27,7 +27,7 @@ protected:
 
 public:
 	CyclicString();
-	CyclicString(std::vector<alphabet::Symbol>& data);
+	explicit CyclicString(std::vector<alphabet::Symbol>& data);
 	
 	/**
 	 * @return the input alphabet
diff --git a/alib2/src/string/String.h b/alib2/src/string/String.h
index 436163210b..1f0e164e6d 100644
--- a/alib2/src/string/String.h
+++ b/alib2/src/string/String.h
@@ -27,7 +27,7 @@ protected:
 
 public:
 	String();
-	String(std::vector<alphabet::Symbol>& data);
+	explicit String(std::vector<alphabet::Symbol>& data);
 	
 	/**
 	 * @return the input alphabet
-- 
GitLab