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
template <typename T>
struct reverse {
reverse (T &_target):
explicit reverse (T &_target):
m_target (_target)
{ ; }
@ -49,7 +49,7 @@ namespace util::adapter {
struct indices {
using typename T::size_type;
indices (T &_target):
explicit indices (T &_target):
m_target (_target)
{ ; }
@ -79,7 +79,7 @@ namespace util::adapter {
using reference = typename std::iterator_traits<scalar<I,It>>::reference;
using value_type = typename std::iterator_traits<scalar<I,It>>::value_type;
scalar (It _inner):
explicit scalar (It _inner):
m_inner (_inner)
{ ; }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

4
io.hpp
View File

@ -69,7 +69,7 @@ namespace util {
//-------------------------------------------------------------------------
template <typename T>
struct indented {
indented (const T &_data);
explicit indented (const T &_data);
const T &data;
};
@ -100,7 +100,7 @@ namespace util {
//-------------------------------------------------------------------------
class path_error : public std::runtime_error {
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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,7 +25,7 @@ namespace util::stream {
#define SCOPED(NAME,TYPE) \
class NAME { \
public: \
NAME (std::ios_base&); \
explicit NAME (std::ios_base&); \
~NAME (); \
\
private: \

View File

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