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 class dynlib
{ {
public: public:
dynlib(const pstring libname); explicit dynlib(const pstring libname);
dynlib(const pstring path, const pstring libname); dynlib(const pstring path, const pstring libname);
~dynlib(); ~dynlib();

View File

@ -154,8 +154,8 @@ protected:
class pfmt : public pformat_base<pfmt> class pfmt : public pformat_base<pfmt>
{ {
public: public:
pfmt(const pstring &fmt); explicit pfmt(const pstring &fmt);
pfmt(const char *fmt); explicit pfmt(const char *fmt);
virtual ~pfmt(); virtual ~pfmt();
operator pstring() const { return m_str; } 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> class plog_channel : public pfmt_writer_t<build_enabled>
{ {
public: 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() { } virtual ~plog_channel() { }
protected: protected:
@ -270,7 +270,7 @@ class plog_base
{ {
public: public:
plog_base(plog_dispatch_intf *proxy) explicit plog_base(plog_dispatch_intf *proxy)
: debug(proxy), : debug(proxy),
info(proxy), info(proxy),
verbose(proxy), verbose(proxy),

View File

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

View File

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

View File

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