build: make single argument constructors explicit

This commit is contained in:
Danny Robson 2015-06-04 22:18:43 +10:00
parent 72797793e9
commit fd319d579b
20 changed files with 32 additions and 32 deletions

View File

@ -27,7 +27,7 @@ namespace util { namespace crypto {
public:
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 decrypt (uint32_t *restrict data, size_t count);

View File

@ -27,7 +27,7 @@ namespace util { namespace crypto {
public:
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 decrypt (uint32_t *restrict data, size_t count);

View File

@ -28,7 +28,7 @@ namespace util { namespace crypto {
public:
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 decrypt (uint32_t *restrict data, size_t count);

View File

@ -282,7 +282,7 @@ class panic_error {
std::string m_what;
public:
panic_error (const std::string &_what):
explicit panic_error (const std::string &_what):
m_what (_what)
{ ; }
};

View File

@ -76,7 +76,7 @@ template <typename T> constexpr T ltoh (T v) { return v; }
//-----------------------------------------------------------------------------
struct from_endian {
from_endian (endian _endian):
explicit from_endian (endian _endian):
src (_endian)
{ ; }

View File

@ -34,9 +34,9 @@ namespace util {
typedef native_t integer_t;
fixed (double);
fixed (float);
fixed (native_t);
explicit fixed (double);
explicit fixed (float);
explicit fixed (native_t);
double to_double (void) const;
float to_float (void) const;

View File

@ -34,7 +34,7 @@ class guid {
public:
guid (uint32_t, uint16_t, uint16_t, uint8_t[8]);
guid (const char *);
explicit guid (const char *);
guid (const guid&);
guid& operator= (const guid&);

8
ip.hpp
View File

@ -30,8 +30,8 @@ namespace ipv4 {
uint32_t m_integer;
};
ip (const std::string &);
ip (uint32_t i);
explicit ip (const std::string &);
explicit ip (uint32_t i);
ip (uint8_t a, uint8_t b, uint8_t c, uint8_t d);
ip& operator = (const ip &);
@ -59,7 +59,7 @@ namespace ipv6 {
struct ip {
uint32_t m_quads[4];
ip (const std::string&) { ; }
explicit ip (const std::string&) { ; }
};
typedef uint16_t port;
@ -67,7 +67,7 @@ namespace ipv6 {
struct mask {
uint32_t m_quads[4];
mask (uint32_t) { ; }
explicit mask (uint32_t) { ; }
};
}

View File

@ -38,7 +38,7 @@ namespace json {
struct parse_error : public 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;
};
@ -52,7 +52,7 @@ namespace json {
/// Exception class for invalid object indexing
struct key_error : public error {
key_error (std::string);
explicit key_error (std::string);
};
}

View File

@ -20,7 +20,7 @@
template <typename T>
class scoped_malloc {
public:
scoped_malloc (T *_data):
explicit scoped_malloc (T *_data):
m_data (_data)
{ ; }

View File

@ -71,7 +71,7 @@ namespace net {
static const address<D> LOOPBACK;
static const address<D> ANY;
address (const sockaddr_type &);
explicit address (const sockaddr_type &);
address (const std::string &address, port_type);
port_type port (void) const;

View File

@ -32,8 +32,8 @@
namespace net {
class error : public std::runtime_error {
protected:
error (const std::string &);
error (int code);
explicit error (const std::string &);
explicit error (int code);
static std::string
code_to_string (int code);

View File

@ -232,7 +232,7 @@ net::socket<D, type::STREAM>::get_peer (void) const {
net::error::throw_code ();
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)
net::error::throw_code ();
return addr_in;
return net::socket<D,type::DGRAM>::address_type (addr_in);
}
//-----------------------------------------------------------------------------

View File

@ -26,7 +26,7 @@ namespace util {
/// Increments a counter for the lifetime of the object
template <typename T>
struct scoped_counter {
scoped_counter (T &_counter):
explicit scoped_counter (T &_counter):
counter (_counter)
{ ++counter; }
@ -40,7 +40,7 @@ namespace util {
/// Executes a function upon object destruction
template <typename T>
struct scoped_function {
scoped_function (T &&_func):
explicit scoped_function (T &&_func):
func (std::move (_func))
{ ; }

View File

@ -26,7 +26,7 @@ namespace util {
template <typename T>
struct numeric
{
numeric (T _val): val (_val) { ; }
explicit numeric (T _val): val (_val) { ; }
T val;
};

View File

@ -9,8 +9,8 @@ test_simple (util::TAP::logger &tap)
using fixed_t = util::fixed<T,I,E>;
using integer_t = typename fixed_t::integer_t;
const fixed_t lo = integer_t{0};
const fixed_t hi = integer_t{1};
const fixed_t lo {integer_t{0}};
const fixed_t hi {integer_t{1}};
std::ostringstream os;
os << "fixed<" << type_to_string<T> () << ',' << I << ',' << E << '>';

View File

@ -27,8 +27,8 @@
namespace util {
class uri {
public:
uri (std::string &&);
uri (const char *str);
explicit uri (std::string &&);
explicit uri (const char *str);
uri (const char *first, const char *last);
class parse_error : public std::runtime_error

View File

@ -33,8 +33,8 @@ namespace util {
version ();
version (unsigned int _major, unsigned int _minor);
version (const std::string& str);
version (const char *str);
explicit version (const std::string& str);
explicit version (const char *str);
void sanity (void) const;

View File

@ -25,7 +25,7 @@ namespace util {
class view {
public:
view ();
view (const char *str);
explicit view (const char *str);
view (const char *first, const char *last);
const char *begin (void) const;

View File

@ -55,7 +55,7 @@ namespace util {
static void try_code (int code);
static void throw_code (int code);
error(const std::string&);
explicit error(const std::string&);
};