Fix single parameter constructors found by cppcheck

This commit is contained in:
Jason Turner 2016-10-28 15:49:40 -06:00
parent b1f1803759
commit 28122f7cb0
14 changed files with 33 additions and 33 deletions

View File

@ -28,7 +28,7 @@ namespace chaiscript
{
struct arithmetic_error : std::runtime_error
{
arithmetic_error(const std::string& reason) : std::runtime_error("Arithmetic error: " + reason) {}
explicit arithmetic_error(const std::string& reason) : std::runtime_error("Arithmetic error: " + reason) {}
arithmetic_error(const arithmetic_error &) = default;
~arithmetic_error() noexcept override = default;
};

View File

@ -25,7 +25,7 @@ namespace chaiscript {
template<typename Ret, typename Class, typename ... Param>
struct Const_Caller
{
Const_Caller(Ret (Class::*t_func)(Param...) const) : m_func(t_func) {}
explicit Const_Caller(Ret (Class::*t_func)(Param...) const) : m_func(t_func) {}
template<typename ... Inner>
Ret operator()(const Class &o, Inner&& ... inner) const {
@ -38,7 +38,7 @@ namespace chaiscript {
template<typename Ret, typename ... Param>
struct Fun_Caller
{
Fun_Caller(Ret( * t_func)(Param...) ) : m_func(t_func) {}
explicit Fun_Caller(Ret( * t_func)(Param...) ) : m_func(t_func) {}
template<typename ... Inner>
Ret operator()(Inner&& ... inner) const {
@ -51,7 +51,7 @@ namespace chaiscript {
template<typename Ret, typename Class, typename ... Param>
struct Caller
{
Caller(Ret (Class::*t_func)(Param...)) : m_func(t_func) {}
explicit Caller(Ret (Class::*t_func)(Param...)) : m_func(t_func) {}
template<typename ... Inner>
Ret operator()(Class &o, Inner&& ... inner) const {

View File

@ -266,7 +266,7 @@ namespace chaiscript
class Dispatch_Function final : public dispatch::Proxy_Function_Base
{
public:
Dispatch_Function(std::vector<Proxy_Function> t_funcs)
explicit Dispatch_Function(std::vector<Proxy_Function> t_funcs)
: Proxy_Function_Base(build_type_infos(t_funcs), calculate_arity(t_funcs)),
m_funcs(std::move(t_funcs))
{
@ -447,7 +447,7 @@ namespace chaiscript
Type_Name_Map m_types;
};
Dispatch_Engine(chaiscript::parser::ChaiScript_Parser_Base &parser)
explicit Dispatch_Engine(chaiscript::parser::ChaiScript_Parser_Base &parser)
: m_stack_holder(this),
m_parser(parser)
{
@ -1516,7 +1516,7 @@ namespace chaiscript
class Dispatch_State
{
public:
Dispatch_State(Dispatch_Engine &t_engine)
explicit Dispatch_State(Dispatch_Engine &t_engine)
: m_engine(t_engine),
m_stack_holder(t_engine.get_stack_holder()),
m_conversions(t_engine.conversions(), t_engine.conversions().conversion_saves())

View File

@ -25,7 +25,7 @@ namespace chaiscript
namespace dispatch
{
struct option_explicit_set : std::runtime_error {
option_explicit_set(const std::string &t_param_name)
explicit option_explicit_set(const std::string &t_param_name)
: std::runtime_error("option explicit set and parameter '" + t_param_name + "' does not exist")
{
@ -39,7 +39,7 @@ namespace chaiscript
class Dynamic_Object
{
public:
Dynamic_Object(std::string t_type_name)
explicit Dynamic_Object(std::string t_type_name)
: m_type_name(std::move(t_type_name)), m_option_explicit(false)
{
}

View File

@ -53,7 +53,7 @@ namespace chaiscript
m_doti(user_type<Dynamic_Object>())
{}
Param_Types(std::vector<std::pair<std::string, Type_Info>> t_types)
explicit Param_Types(std::vector<std::pair<std::string, Type_Info>> t_types)
: m_types(std::move(t_types)),
m_has_types(false),
m_doti(user_type<Dynamic_Object>())
@ -529,7 +529,7 @@ namespace chaiscript
class Proxy_Function_Impl_Base : public Proxy_Function_Base
{
public:
Proxy_Function_Impl_Base(const std::vector<Type_Info> &t_types)
explicit Proxy_Function_Impl_Base(const std::vector<Type_Info> &t_types)
: Proxy_Function_Base(t_types, static_cast<int>(t_types.size()) - 1)
{
}
@ -550,7 +550,7 @@ namespace chaiscript
class Proxy_Function_Callable_Impl final : public Proxy_Function_Impl_Base
{
public:
Proxy_Function_Callable_Impl(Callable f)
explicit Proxy_Function_Callable_Impl(Callable f)
: Proxy_Function_Impl_Base(detail::build_param_type_list(static_cast<Func *>(nullptr))),
m_f(std::move(f))
{
@ -581,7 +581,7 @@ namespace chaiscript
class Assignable_Proxy_Function : public Proxy_Function_Impl_Base
{
public:
Assignable_Proxy_Function(const std::vector<Type_Info> &t_types)
explicit Assignable_Proxy_Function(const std::vector<Type_Info> &t_types)
: Proxy_Function_Impl_Base(t_types)
{
}
@ -637,7 +637,7 @@ namespace chaiscript
class Attribute_Access final : public Proxy_Function_Base
{
public:
Attribute_Access(T Class::* t_attr)
explicit Attribute_Access(T Class::* t_attr)
: Proxy_Function_Base(param_types(), 1),
m_attr(t_attr)
{

View File

@ -110,13 +110,13 @@ public:
short_alloc(const short_alloc&) = default;
short_alloc& operator=(const short_alloc&) = delete;
short_alloc(arena_type& a) noexcept : a_(a)
explicit short_alloc(arena_type& a) noexcept : a_(a)
{
static_assert(size % alignment == 0,
"size N needs to be a multiple of alignment Align");
}
template <class U>
short_alloc(const short_alloc<U, N, alignment>& a) noexcept
explicit short_alloc(const short_alloc<U, N, alignment>& a) noexcept
: a_(a.a_) {}
template <class _Up> struct rebind {using other = short_alloc<_Up, N, alignment>;};

View File

@ -39,7 +39,7 @@ namespace chaiscript
{
}
bad_boxed_dynamic_cast(const std::string &w) noexcept
explicit bad_boxed_dynamic_cast(const std::string &w) noexcept
: bad_boxed_cast(w)
{
}
@ -63,7 +63,7 @@ namespace chaiscript
{
}
bad_boxed_type_cast(const std::string &w) noexcept
explicit bad_boxed_type_cast(const std::string &w) noexcept
: bad_boxed_cast(w)
{
}

View File

@ -130,7 +130,7 @@ namespace chaiscript
/// \brief Thrown if an error occurs while attempting to load a binary module
struct load_module_error : std::runtime_error
{
load_module_error(const std::string &t_reason) noexcept
explicit load_module_error(const std::string &t_reason) noexcept
: std::runtime_error(t_reason)
{
}
@ -188,7 +188,7 @@ namespace chaiscript
reason(t_why), start_position(t_where), filename(t_fname)
{}
eval_error(const std::string &t_why) noexcept
explicit eval_error(const std::string &t_why) noexcept
: std::runtime_error("Error: \"" + t_why + "\" "),
reason(t_why)
{}
@ -476,7 +476,7 @@ namespace chaiscript
/// Errors generated when loading a file
struct file_not_found_error : std::runtime_error {
file_not_found_error(const std::string &t_filename) noexcept
explicit file_not_found_error(const std::string &t_filename) noexcept
: std::runtime_error("File Not Found: " + t_filename)
{ }
@ -597,7 +597,7 @@ namespace chaiscript
struct Return_Value {
Boxed_Value retval;
Return_Value(Boxed_Value t_return_value) : retval(std::move(t_return_value)) { }
explicit Return_Value(Boxed_Value t_return_value) : retval(std::move(t_return_value)) { }
};
@ -621,7 +621,7 @@ namespace chaiscript
Scope_Push_Pop(const Scope_Push_Pop &) = delete;
Scope_Push_Pop& operator=(const Scope_Push_Pop &) = delete;
Scope_Push_Pop(const chaiscript::detail::Dispatch_State &t_ds)
explicit Scope_Push_Pop(const chaiscript::detail::Dispatch_State &t_ds)
: m_ds(t_ds)
{
m_ds->new_scope(m_ds.stack_holder());
@ -645,7 +645,7 @@ namespace chaiscript
Function_Push_Pop(const Function_Push_Pop &) = delete;
Function_Push_Pop& operator=(const Function_Push_Pop &) = delete;
Function_Push_Pop(const chaiscript::detail::Dispatch_State &t_ds)
explicit Function_Push_Pop(const chaiscript::detail::Dispatch_State &t_ds)
: m_ds(t_ds)
{
m_ds->new_function_call(m_ds.stack_holder(), m_ds.conversion_saves());
@ -679,7 +679,7 @@ namespace chaiscript
Stack_Push_Pop(const Stack_Push_Pop &) = delete;
Stack_Push_Pop& operator=(const Stack_Push_Pop &) = delete;
Stack_Push_Pop(const chaiscript::detail::Dispatch_State &t_ds)
explicit Stack_Push_Pop(const chaiscript::detail::Dispatch_State &t_ds)
: m_ds(t_ds)
{
m_ds->new_stack(m_ds.stack_holder());

View File

@ -79,7 +79,7 @@ namespace chaiscript
{
try {
const auto p = m_parser->parse(t_input, t_filename);
return p->eval(m_engine);
return p->eval(chaiscript::detail::Dispatch_State(m_engine));
}
catch (chaiscript::eval::detail::Return_Value &rv) {
return rv.retval;
@ -284,7 +284,7 @@ namespace chaiscript
///
/// \param[in] t_modulepaths Vector of paths to search when attempting to load a binary module
/// \param[in] t_usepaths Vector of paths to search when attempting to "use" an included ChaiScript file
ChaiScript_Basic(std::unique_ptr<parser::ChaiScript_Parser_Base> &&parser,
explicit ChaiScript_Basic(std::unique_ptr<parser::ChaiScript_Parser_Base> &&parser,
std::vector<std::string> t_module_paths = {},
std::vector<std::string> t_use_paths = {},
const std::vector<chaiscript::Options> &t_opts = chaiscript::default_options())
@ -315,7 +315,7 @@ namespace chaiscript
const Boxed_Value eval(const AST_NodePtr &t_ast)
{
try {
return t_ast->eval(m_engine);
return t_ast->eval(chaiscript::detail::Dispatch_State(m_engine));
} catch (const exception::eval_error &t_ee) {
throw Boxed_Value(t_ee);
}

View File

@ -238,7 +238,7 @@ namespace chaiscript
{
}
Constant_AST_Node(Boxed_Value t_value)
explicit Constant_AST_Node(Boxed_Value t_value)
: AST_Node_Impl<T>("", AST_Node_Type::Constant, Parse_Location()),
m_value(std::move(t_value))
{

View File

@ -17,7 +17,7 @@ namespace chaiscript {
struct Optimizer : T...
{
Optimizer() = default;
Optimizer(T ... t)
explicit Optimizer(T ... t)
: T(std::move(t))...
{
}

View File

@ -15,7 +15,7 @@ namespace chaiscript
{
struct DLModule
{
DLModule(const std::string &t_filename)
explicit DLModule(const std::string &t_filename)
: m_data(dlopen(t_filename.c_str(), RTLD_NOW))
{
if (m_data == nullptr)

View File

@ -23,7 +23,7 @@ namespace chaiscript {
struct Tracer : T...
{
Tracer() = default;
Tracer(T ... t)
explicit Tracer(T ... t)
: T(std::move(t))...
{
}

View File

@ -80,7 +80,7 @@ namespace chaiscript
struct DLModule
{
DLModule(const std::string &t_filename)
explicit DLModule(const std::string &t_filename)
: m_data(LoadLibrary(to_proper_string(t_filename).c_str()))
{
if (!m_data)