build: make single argument constructors explicit
This commit is contained in:
parent
72797793e9
commit
fd319d579b
@ -27,7 +27,7 @@ namespace util { namespace crypto {
|
|||||||
public:
|
public:
|
||||||
using key_t = std::array<uint32_t,4>;
|
using key_t = std::array<uint32_t,4>;
|
||||||
|
|
||||||
TEA (key_t);
|
explicit TEA (key_t);
|
||||||
|
|
||||||
void encrypt (uint32_t *restrict data, size_t count);
|
void encrypt (uint32_t *restrict data, size_t count);
|
||||||
void decrypt (uint32_t *restrict data, size_t count);
|
void decrypt (uint32_t *restrict data, size_t count);
|
||||||
|
@ -27,7 +27,7 @@ namespace util { namespace crypto {
|
|||||||
public:
|
public:
|
||||||
using key_t = std::array<uint32_t,4>;
|
using key_t = std::array<uint32_t,4>;
|
||||||
|
|
||||||
XTEA (key_t);
|
explicit XTEA (key_t);
|
||||||
|
|
||||||
void encrypt (uint32_t *restrict data, size_t count);
|
void encrypt (uint32_t *restrict data, size_t count);
|
||||||
void decrypt (uint32_t *restrict data, size_t count);
|
void decrypt (uint32_t *restrict data, size_t count);
|
||||||
|
@ -28,7 +28,7 @@ namespace util { namespace crypto {
|
|||||||
public:
|
public:
|
||||||
using key_t = std::array<uint32_t,4>;
|
using key_t = std::array<uint32_t,4>;
|
||||||
|
|
||||||
XXTEA (key_t);
|
explicit XXTEA (key_t);
|
||||||
|
|
||||||
void encrypt (uint32_t *restrict data, size_t count);
|
void encrypt (uint32_t *restrict data, size_t count);
|
||||||
void decrypt (uint32_t *restrict data, size_t count);
|
void decrypt (uint32_t *restrict data, size_t count);
|
||||||
|
@ -282,7 +282,7 @@ class panic_error {
|
|||||||
std::string m_what;
|
std::string m_what;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
panic_error (const std::string &_what):
|
explicit panic_error (const std::string &_what):
|
||||||
m_what (_what)
|
m_what (_what)
|
||||||
{ ; }
|
{ ; }
|
||||||
};
|
};
|
||||||
|
@ -76,7 +76,7 @@ template <typename T> constexpr T ltoh (T v) { return v; }
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
struct from_endian {
|
struct from_endian {
|
||||||
from_endian (endian _endian):
|
explicit from_endian (endian _endian):
|
||||||
src (_endian)
|
src (_endian)
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
|
@ -34,9 +34,9 @@ namespace util {
|
|||||||
|
|
||||||
typedef native_t integer_t;
|
typedef native_t integer_t;
|
||||||
|
|
||||||
fixed (double);
|
explicit fixed (double);
|
||||||
fixed (float);
|
explicit fixed (float);
|
||||||
fixed (native_t);
|
explicit fixed (native_t);
|
||||||
|
|
||||||
double to_double (void) const;
|
double to_double (void) const;
|
||||||
float to_float (void) const;
|
float to_float (void) const;
|
||||||
|
2
guid.hpp
2
guid.hpp
@ -34,7 +34,7 @@ class guid {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
guid (uint32_t, uint16_t, uint16_t, uint8_t[8]);
|
guid (uint32_t, uint16_t, uint16_t, uint8_t[8]);
|
||||||
guid (const char *);
|
explicit guid (const char *);
|
||||||
guid (const guid&);
|
guid (const guid&);
|
||||||
|
|
||||||
guid& operator= (const guid&);
|
guid& operator= (const guid&);
|
||||||
|
8
ip.hpp
8
ip.hpp
@ -30,8 +30,8 @@ namespace ipv4 {
|
|||||||
uint32_t m_integer;
|
uint32_t m_integer;
|
||||||
};
|
};
|
||||||
|
|
||||||
ip (const std::string &);
|
explicit ip (const std::string &);
|
||||||
ip (uint32_t i);
|
explicit ip (uint32_t i);
|
||||||
ip (uint8_t a, uint8_t b, uint8_t c, uint8_t d);
|
ip (uint8_t a, uint8_t b, uint8_t c, uint8_t d);
|
||||||
|
|
||||||
ip& operator = (const ip &);
|
ip& operator = (const ip &);
|
||||||
@ -59,7 +59,7 @@ namespace ipv6 {
|
|||||||
struct ip {
|
struct ip {
|
||||||
uint32_t m_quads[4];
|
uint32_t m_quads[4];
|
||||||
|
|
||||||
ip (const std::string&) { ; }
|
explicit ip (const std::string&) { ; }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef uint16_t port;
|
typedef uint16_t port;
|
||||||
@ -67,7 +67,7 @@ namespace ipv6 {
|
|||||||
struct mask {
|
struct mask {
|
||||||
uint32_t m_quads[4];
|
uint32_t m_quads[4];
|
||||||
|
|
||||||
mask (uint32_t) { ; }
|
explicit mask (uint32_t) { ; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ namespace json {
|
|||||||
struct parse_error : public error {
|
struct parse_error : public error {
|
||||||
using error::error;
|
using error::error;
|
||||||
|
|
||||||
parse_error (const std::string &_what, size_t _line = 0);
|
explicit parse_error (const std::string &_what, size_t _line = 0);
|
||||||
|
|
||||||
size_t line;
|
size_t line;
|
||||||
};
|
};
|
||||||
@ -52,7 +52,7 @@ namespace json {
|
|||||||
|
|
||||||
/// Exception class for invalid object indexing
|
/// Exception class for invalid object indexing
|
||||||
struct key_error : public error {
|
struct key_error : public error {
|
||||||
key_error (std::string);
|
explicit key_error (std::string);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
class scoped_malloc {
|
class scoped_malloc {
|
||||||
public:
|
public:
|
||||||
scoped_malloc (T *_data):
|
explicit scoped_malloc (T *_data):
|
||||||
m_data (_data)
|
m_data (_data)
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ namespace net {
|
|||||||
static const address<D> LOOPBACK;
|
static const address<D> LOOPBACK;
|
||||||
static const address<D> ANY;
|
static const address<D> ANY;
|
||||||
|
|
||||||
address (const sockaddr_type &);
|
explicit address (const sockaddr_type &);
|
||||||
address (const std::string &address, port_type);
|
address (const std::string &address, port_type);
|
||||||
|
|
||||||
port_type port (void) const;
|
port_type port (void) const;
|
||||||
|
@ -32,8 +32,8 @@
|
|||||||
namespace net {
|
namespace net {
|
||||||
class error : public std::runtime_error {
|
class error : public std::runtime_error {
|
||||||
protected:
|
protected:
|
||||||
error (const std::string &);
|
explicit error (const std::string &);
|
||||||
error (int code);
|
explicit error (int code);
|
||||||
|
|
||||||
static std::string
|
static std::string
|
||||||
code_to_string (int code);
|
code_to_string (int code);
|
||||||
|
@ -232,7 +232,7 @@ net::socket<D, type::STREAM>::get_peer (void) const {
|
|||||||
net::error::throw_code ();
|
net::error::throw_code ();
|
||||||
|
|
||||||
CHECK (addr_len == sizeof (addr));
|
CHECK (addr_len == sizeof (addr));
|
||||||
return addr;
|
return typename net::socket<D,type::STREAM>::address_type (addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -288,7 +288,7 @@ net::socket<D, type::DGRAM>::recv_addr (uint8_t *restrict data,
|
|||||||
if (recvd < 0)
|
if (recvd < 0)
|
||||||
net::error::throw_code ();
|
net::error::throw_code ();
|
||||||
|
|
||||||
return addr_in;
|
return net::socket<D,type::DGRAM>::address_type (addr_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
4
raii.hpp
4
raii.hpp
@ -26,7 +26,7 @@ namespace util {
|
|||||||
/// Increments a counter for the lifetime of the object
|
/// Increments a counter for the lifetime of the object
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct scoped_counter {
|
struct scoped_counter {
|
||||||
scoped_counter (T &_counter):
|
explicit scoped_counter (T &_counter):
|
||||||
counter (_counter)
|
counter (_counter)
|
||||||
{ ++counter; }
|
{ ++counter; }
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ namespace util {
|
|||||||
/// Executes a function upon object destruction
|
/// Executes a function upon object destruction
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct scoped_function {
|
struct scoped_function {
|
||||||
scoped_function (T &&_func):
|
explicit scoped_function (T &&_func):
|
||||||
func (std::move (_func))
|
func (std::move (_func))
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ namespace util {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
struct numeric
|
struct numeric
|
||||||
{
|
{
|
||||||
numeric (T _val): val (_val) { ; }
|
explicit numeric (T _val): val (_val) { ; }
|
||||||
T val;
|
T val;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ test_simple (util::TAP::logger &tap)
|
|||||||
using fixed_t = util::fixed<T,I,E>;
|
using fixed_t = util::fixed<T,I,E>;
|
||||||
using integer_t = typename fixed_t::integer_t;
|
using integer_t = typename fixed_t::integer_t;
|
||||||
|
|
||||||
const fixed_t lo = integer_t{0};
|
const fixed_t lo {integer_t{0}};
|
||||||
const fixed_t hi = integer_t{1};
|
const fixed_t hi {integer_t{1}};
|
||||||
|
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "fixed<" << type_to_string<T> () << ',' << I << ',' << E << '>';
|
os << "fixed<" << type_to_string<T> () << ',' << I << ',' << E << '>';
|
||||||
|
4
uri.hpp
4
uri.hpp
@ -27,8 +27,8 @@
|
|||||||
namespace util {
|
namespace util {
|
||||||
class uri {
|
class uri {
|
||||||
public:
|
public:
|
||||||
uri (std::string &&);
|
explicit uri (std::string &&);
|
||||||
uri (const char *str);
|
explicit uri (const char *str);
|
||||||
uri (const char *first, const char *last);
|
uri (const char *first, const char *last);
|
||||||
|
|
||||||
class parse_error : public std::runtime_error
|
class parse_error : public std::runtime_error
|
||||||
|
@ -33,8 +33,8 @@ namespace util {
|
|||||||
|
|
||||||
version ();
|
version ();
|
||||||
version (unsigned int _major, unsigned int _minor);
|
version (unsigned int _major, unsigned int _minor);
|
||||||
version (const std::string& str);
|
explicit version (const std::string& str);
|
||||||
version (const char *str);
|
explicit version (const char *str);
|
||||||
|
|
||||||
void sanity (void) const;
|
void sanity (void) const;
|
||||||
|
|
||||||
|
2
view.hpp
2
view.hpp
@ -25,7 +25,7 @@ namespace util {
|
|||||||
class view {
|
class view {
|
||||||
public:
|
public:
|
||||||
view ();
|
view ();
|
||||||
view (const char *str);
|
explicit view (const char *str);
|
||||||
view (const char *first, const char *last);
|
view (const char *first, const char *last);
|
||||||
|
|
||||||
const char *begin (void) const;
|
const char *begin (void) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user