build: use explicit constructors

This commit is contained in:
Danny Robson 2017-05-23 12:50:51 +10:00
parent 30fa4a378d
commit 25e19b5810
17 changed files with 38 additions and 38 deletions

View File

@ -26,7 +26,7 @@ namespace util::adapter {
// reverse a container for range-based-for // reverse a container for range-based-for
template <typename T> template <typename T>
struct reverse { struct reverse {
reverse (T &_target): explicit reverse (T &_target):
m_target (_target) m_target (_target)
{ ; } { ; }
@ -49,7 +49,7 @@ namespace util::adapter {
struct indices { struct indices {
using typename T::size_type; using typename T::size_type;
indices (T &_target): explicit indices (T &_target):
m_target (_target) m_target (_target)
{ ; } { ; }
@ -79,7 +79,7 @@ namespace util::adapter {
using reference = typename std::iterator_traits<scalar<I,It>>::reference; using reference = typename std::iterator_traits<scalar<I,It>>::reference;
using value_type = typename std::iterator_traits<scalar<I,It>>::value_type; using value_type = typename std::iterator_traits<scalar<I,It>>::value_type;
scalar (It _inner): explicit scalar (It _inner):
m_inner (_inner) m_inner (_inner)
{ ; } { ; }

View File

@ -28,7 +28,7 @@ namespace util::alloc {
typedef T value_type; typedef T value_type;
template <typename ...Args> template <typename ...Args>
allocator (Args&& ...args); explicit allocator (Args&& ...args);
T* allocate (size_t count); T* allocate (size_t count);
void deallocate (T*, size_t count); void deallocate (T*, size_t count);

View File

@ -26,7 +26,7 @@ namespace util::alloc {
template <class T> template <class T>
class arena { class arena {
public: public:
arena (T &store); explicit arena (T &store);
//--------------------------------------------------------------------- //---------------------------------------------------------------------
template <typename U, typename ...Args> template <typename U, typename ...Args>

View File

@ -117,7 +117,7 @@ namespace util::cmdopt {
class bytes : public value<size_t> { class bytes : public value<size_t> {
public: public:
bytes (size_t &_value): value (_value) { } explicit bytes (size_t &_value): value (_value) { }
using value<size_t>::execute; using value<size_t>::execute;
void execute (const char *restrict) override; void execute (const char *restrict) override;
@ -168,7 +168,7 @@ namespace util::cmdopt {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
class invalid_key : public error { class invalid_key : public error {
public: public:
invalid_key (std::string _key); explicit invalid_key (std::string _key);
const char* what (void) const noexcept override; const char* what (void) const noexcept override;
private: private:
@ -178,7 +178,7 @@ namespace util::cmdopt {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
class invalid_value : public error { class invalid_value : public error {
public: public:
invalid_value (std::string _value); explicit invalid_value (std::string _value);
const char* what (void) const noexcept override; const char* what (void) const noexcept override;
private: private:
@ -200,7 +200,7 @@ namespace util::cmdopt {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
class unhandled_argument : public error { class unhandled_argument : public error {
public: public:
unhandled_argument (int index); explicit unhandled_argument (int index);
const char* what (void) const noexcept override; const char* what (void) const noexcept override;
int index (void) const noexcept; int index (void) const noexcept;

View File

@ -25,7 +25,7 @@
namespace util { namespace util {
class input_error : public std::runtime_error { class input_error : public std::runtime_error {
public: public:
input_error (const std::string &_what): explicit input_error (const std::string &_what):
runtime_error (_what) runtime_error (_what)
{ ; } { ; }
}; };
@ -33,7 +33,7 @@ namespace util {
class output_error : public std::runtime_error { class output_error : public std::runtime_error {
public: public:
output_error (const std::string &_what): explicit output_error (const std::string &_what):
runtime_error (_what) runtime_error (_what)
{ ; } { ; }
}; };
@ -41,7 +41,7 @@ namespace util {
class unavailable_error : public std::runtime_error { class unavailable_error : public std::runtime_error {
public: public:
unavailable_error (const std::string &_what): explicit unavailable_error (const std::string &_what):
runtime_error (_what) runtime_error (_what)
{ ; } { ; }
}; };
@ -50,7 +50,7 @@ namespace util {
/// An exception class used for reporting errors signalled by errno. /// An exception class used for reporting errors signalled by errno.
class errno_error : public std::runtime_error { class errno_error : public std::runtime_error {
public: public:
errno_error (int code); explicit errno_error (int code);
errno_error (); errno_error ();
int code (void) const; int code (void) const;
@ -73,7 +73,7 @@ namespace util {
namespace util { namespace util {
class win32_error : public std::runtime_error { class win32_error : public std::runtime_error {
public: public:
win32_error (DWORD _code); explicit win32_error (DWORD _code);
win32_error (); win32_error ();
DWORD code (void) const; DWORD code (void) const;

View File

@ -29,7 +29,7 @@ namespace std::experimental::filesystem {
static constexpr value_type preferred_separator = '/'; static constexpr value_type preferred_separator = '/';
path (); path ();
path (const path&); explicit path (const path&);
template <class Source> template <class Source>
path (const Source &s): path (const Source &s):

View File

@ -53,7 +53,7 @@ namespace util::format {
public: public:
using value_type = ValueT; using value_type = ValueT;
invalid_specifier (char specifier); explicit invalid_specifier (char specifier);
char specifier (void) const; char specifier (void) const;

4
io.hpp
View File

@ -69,7 +69,7 @@ namespace util {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
template <typename T> template <typename T>
struct indented { struct indented {
indented (const T &_data); explicit indented (const T &_data);
const T &data; const T &data;
}; };
@ -100,7 +100,7 @@ namespace util {
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
class path_error : public std::runtime_error { class path_error : public std::runtime_error {
public: public:
path_error (const std::experimental::filesystem::path &path); explicit path_error (const std::experimental::filesystem::path &path);
const std::experimental::filesystem::path& path (void) const noexcept; const std::experimental::filesystem::path& path (void) const noexcept;

View File

@ -24,7 +24,7 @@
namespace json { namespace json {
/// The base class for all exceptions throw directly by the json namespace. /// The base class for all exceptions throw directly by the json namespace.
struct error : public std::runtime_error { struct error : public std::runtime_error {
error (const std::string &what): explicit error (const std::string &what):
runtime_error (what) runtime_error (what)
{ ; } { ; }
}; };
@ -32,7 +32,7 @@ namespace json {
/// Base class for all type conversion errors /// Base class for all type conversion errors
struct type_error : public error { struct type_error : public error {
type_error (const std::string &what): explicit type_error (const std::string &what):
error (what) error (what)
{ ; } { ; }
}; };
@ -51,7 +51,7 @@ namespace json {
/// Base class for errors thrown during schema validation /// Base class for errors thrown during schema validation
struct schema_error : public error { struct schema_error : public error {
schema_error (const std::string &what): explicit schema_error (const std::string &what):
error (what) error (what)
{ ; } { ; }
}; };

View File

@ -25,7 +25,7 @@ namespace util {
namespace detail::win32 { namespace detail::win32 {
class library { class library {
public: public:
library (const std::experimental::filesystem::path&); explicit library (const std::experimental::filesystem::path&);
~library (); ~library ();
void* symbol (const char *name); void* symbol (const char *name);

View File

@ -25,7 +25,7 @@ namespace util::memory {
public: public:
using func_t = std::function<void(T*)>; using func_t = std::function<void(T*)>;
func_deleter (func_t _func): explicit func_deleter (func_t _func):
m_func (_func) m_func (_func)
{ ; } { ; }

View File

@ -35,7 +35,7 @@ namespace util::rand {
static_assert (std::is_unsigned<T>::value, static_assert (std::is_unsigned<T>::value,
"LCG generates integer overflow which is undefined behaviour for signed types"); "LCG generates integer overflow which is undefined behaviour for signed types");
lcg (T seed); explicit lcg (T seed);
result_type operator() (void); result_type operator() (void);

View File

@ -30,7 +30,7 @@ namespace util::rand {
using value_type = uint32_t; using value_type = uint32_t;
using seed_type = uint64_t; using seed_type = uint64_t;
mwc64x (seed_type); explicit mwc64x (seed_type);
value_type operator() (void); value_type operator() (void);

View File

@ -28,7 +28,7 @@ namespace util::rand {
public: public:
using result_type = T; using result_type = T;
xorshift (T seed); explicit xorshift (T seed);
result_type operator() (void); result_type operator() (void);

View File

@ -109,7 +109,7 @@ namespace util {
template <typename T> template <typename T>
class value_signal : public signal<void(T)> { class value_signal : public signal<void(T)> {
public: public:
value_signal (T); explicit value_signal (T);
value_signal () = default; value_signal () = default;
operator const T&() const; operator const T&() const;

View File

@ -22,15 +22,15 @@
namespace util::stream { namespace util::stream {
namespace scoped { namespace scoped {
#define SCOPED(NAME,TYPE) \ #define SCOPED(NAME,TYPE) \
class NAME { \ class NAME { \
public: \ public: \
NAME (std::ios_base&); \ explicit NAME (std::ios_base&); \
~NAME (); \ ~NAME (); \
\ \
private: \ private: \
std::ios_base &m_ios; \ std::ios_base &m_ios; \
TYPE m_state; \ TYPE m_state; \
} }
SCOPED(flags, std::ios_base::fmtflags); SCOPED(flags, std::ios_base::fmtflags);

View File

@ -48,7 +48,7 @@ namespace util {
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
class period_query { class period_query {
public: public:
period_query (float seconds); explicit period_query (float seconds);
bool poll (void); bool poll (void);
@ -62,7 +62,7 @@ namespace util {
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
class rate_limiter { class rate_limiter {
public: public:
rate_limiter (unsigned rate); explicit rate_limiter (unsigned rate);
void poll (void); void poll (void);