Add explicit to constructors to avoid bad surprises later. (nw)

This commit is contained in:
couriersud 2016-06-24 23:25:46 +02:00
parent 634473c1ff
commit bc37304ef9
7 changed files with 17 additions and 17 deletions

View File

@ -22,7 +22,7 @@ namespace plib {
class dynlib
{
public:
dynlib(const pstring libname);
explicit dynlib(const pstring libname);
dynlib(const pstring path, const pstring libname);
~dynlib();

View File

@ -154,8 +154,8 @@ protected:
class pfmt : public pformat_base<pfmt>
{
public:
pfmt(const pstring &fmt);
pfmt(const char *fmt);
explicit pfmt(const pstring &fmt);
explicit pfmt(const char *fmt);
virtual ~pfmt();
operator pstring() const { return m_str; }
@ -245,7 +245,7 @@ template <plog_level::e L, bool build_enabled = true>
class plog_channel : public pfmt_writer_t<build_enabled>
{
public:
plog_channel(plog_dispatch_intf *b) : pfmt_writer_t<build_enabled>(), m_base(b) { }
explicit plog_channel(plog_dispatch_intf *b) : pfmt_writer_t<build_enabled>(), m_base(b) { }
virtual ~plog_channel() { }
protected:
@ -270,7 +270,7 @@ class plog_base
{
public:
plog_base(plog_dispatch_intf *proxy)
explicit plog_base(plog_dispatch_intf *proxy)
: debug(proxy),
info(proxy),
verbose(proxy),

View File

@ -96,8 +96,8 @@ public:
{
LC* p;
public:
constexpr iter_t(LC* x) noexcept : p(x) {}
iter_t(const iter_t &rhs) noexcept = default;
explicit constexpr iter_t(LC* x) noexcept : p(x) {}
explicit iter_t(const iter_t &rhs) noexcept = default;
iter_t(iter_t &&rhs) noexcept = default;
iter_t& operator++() noexcept {p = p->next();return *this;}
iter_t operator++(int) noexcept {iter_t tmp(*this); operator++(); return tmp;}

View File

@ -111,7 +111,7 @@ class options
public:
options();
options(option *o[]);
explicit options(option *o[]);
~options();

View File

@ -25,7 +25,7 @@ class ptokenizer
public:
virtual ~ptokenizer() {}
ptokenizer(pistream &strm)
explicit ptokenizer(pistream &strm)
: m_strm(strm), m_lineno(1), m_px(0), m_string('"')
{}

View File

@ -30,7 +30,7 @@ public:
datatype_t(std::size_t bsize, bool bptr, bool bintegral, bool bfloat)
: size(bsize), is_ptr(bptr), is_integral(bintegral), is_float(bfloat), is_custom(false)
{}
datatype_t(bool bcustom)
explicit datatype_t(bool bcustom)
: size(0), is_ptr(false), is_integral(false), is_float(false), is_custom(bcustom)
{}

View File

@ -31,7 +31,7 @@ public:
static const pos_type SEEK_EOF = (pos_type) -1;
pstream(const unsigned flags) : m_flags(flags)
explicit pstream(const unsigned flags) : m_flags(flags)
{
}
virtual ~pstream()
@ -99,7 +99,7 @@ class pistream : public pstream
P_PREVENT_COPYING(pistream)
public:
pistream(const unsigned flags) : pstream(flags) {}
explicit pistream(const unsigned flags) : pstream(flags) {}
virtual ~pistream() {}
bool eof() const { return ((flags() & FLAG_EOF) != 0) || bad(); }
@ -134,7 +134,7 @@ class postream : public pstream
P_PREVENT_COPYING(postream)
public:
postream(unsigned flags) : pstream(flags) {}
explicit postream(unsigned flags) : pstream(flags) {}
virtual ~postream() {}
/* this digests linux & dos/windows text files */
@ -230,7 +230,7 @@ class pofilestream : public postream
P_PREVENT_COPYING(pofilestream)
public:
pofilestream(const pstring &fname);
explicit pofilestream(const pstring &fname);
virtual ~pofilestream();
void close();
@ -281,7 +281,7 @@ class pifilestream : public pistream
P_PREVENT_COPYING(pifilestream)
public:
pifilestream(const pstring &fname);
explicit pifilestream(const pstring &fname);
virtual ~pifilestream();
void close();
@ -324,7 +324,7 @@ class pimemstream : public pistream
public:
pimemstream(const void *mem, const pos_type len);
pimemstream(const pomemstream &ostrm);
explicit pimemstream(const pomemstream &ostrm);
virtual ~pimemstream();
protected:
@ -364,7 +364,7 @@ class pstream_fmt_writer_t : public plib::pfmt_writer_t<>
P_PREVENT_COPYING(pstream_fmt_writer_t)
public:
pstream_fmt_writer_t(postream &strm) : m_strm(strm) {}
explicit pstream_fmt_writer_t(postream &strm) : m_strm(strm) {}
virtual ~pstream_fmt_writer_t() { }
protected: