mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-26 05:48:20 +01:00
Declare single-argument (non-converting) constructors "explicit"
In order to avoid unintended implicit conversions.
This commit is contained in:
@@ -167,7 +167,7 @@ namespace tinyformat {
|
||||
class format_error: public std::runtime_error
|
||||
{
|
||||
public:
|
||||
format_error(const std::string &what): std::runtime_error(what) {
|
||||
explicit format_error(const std::string &what): std::runtime_error(what) {
|
||||
}
|
||||
};
|
||||
|
||||
@@ -498,7 +498,7 @@ class FormatArg
|
||||
FormatArg() {}
|
||||
|
||||
template<typename T>
|
||||
FormatArg(const T& value)
|
||||
explicit FormatArg(const T& value)
|
||||
: m_value(static_cast<const void*>(&value)),
|
||||
m_formatImpl(&formatImpl<T>),
|
||||
m_toIntImpl(&toIntImpl<T>)
|
||||
@@ -867,7 +867,7 @@ class FormatListN : public FormatList
|
||||
public:
|
||||
#ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES
|
||||
template<typename... Args>
|
||||
FormatListN(const Args&... args)
|
||||
explicit FormatListN(const Args&... args)
|
||||
: FormatList(&m_formatterStore[0], N),
|
||||
m_formatterStore { FormatArg(args)... }
|
||||
{ static_assert(sizeof...(args) == N, "Number of args must be N"); }
|
||||
@@ -876,7 +876,7 @@ class FormatListN : public FormatList
|
||||
# define TINYFORMAT_MAKE_FORMATLIST_CONSTRUCTOR(n) \
|
||||
\
|
||||
template<TINYFORMAT_ARGTYPES(n)> \
|
||||
FormatListN(TINYFORMAT_VARARGS(n)) \
|
||||
explicit FormatListN(TINYFORMAT_VARARGS(n)) \
|
||||
: FormatList(&m_formatterStore[0], n) \
|
||||
{ assert(n == N); init(0, TINYFORMAT_PASSARGS(n)); } \
|
||||
\
|
||||
|
||||
Reference in New Issue
Block a user