Merge pull request #626 from CTerasa-ep/fix-warnings

Fix several `noexcept` and `possibly dangling reference` warnings
This commit is contained in:
Rob Loach 2025-02-20 09:45:10 -05:00 committed by GitHub
commit f904cd5447
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 14 deletions

View File

@ -31,7 +31,7 @@ namespace chaiscript {
/// structure which holds the internal state of a Boxed_Value /// structure which holds the internal state of a Boxed_Value
/// \todo Get rid of Any and merge it with this, reducing an allocation in the process /// \todo Get rid of Any and merge it with this, reducing an allocation in the process
struct Data { struct Data {
Data(const Type_Info &ti, chaiscript::detail::Any to, bool is_ref, const void *t_void_ptr, bool t_return_value) Data(const Type_Info &ti, chaiscript::detail::Any to, bool is_ref, const void *t_void_ptr, bool t_return_value) noexcept
: m_type_info(ti) : m_type_info(ti)
, m_obj(std::move(to)) , m_obj(std::move(to))
, m_data_ptr(ti.is_const() ? nullptr : const_cast<void *>(t_void_ptr)) , m_data_ptr(ti.is_const() ? nullptr : const_cast<void *>(t_void_ptr))

View File

@ -501,13 +501,7 @@ namespace chaiscript {
} }
Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override { Boxed_Value eval_internal(const chaiscript::detail::Dispatch_State &t_ss) const override {
const std::string &idname = [&]() -> const std::string & { const std::string &idname = (this->children[0]->identifier == AST_Node_Type::Reference) ? this->children[0]->children[0]->text : this->children[0]->text;
if (this->children[0]->identifier == AST_Node_Type::Reference) {
return this->children[0]->children[0]->text;
} else {
return this->children[0]->text;
}
}();
return t_ss->add_global_no_throw(Boxed_Value(), idname); return t_ss->add_global_no_throw(Boxed_Value(), idname);
} }

View File

@ -5,30 +5,30 @@
class TestBaseType { class TestBaseType {
public: public:
TestBaseType() TestBaseType() noexcept
: val(10) : val(10)
, const_val(15) , const_val(15)
, mdarray{} { , mdarray{} {
} }
TestBaseType(int) TestBaseType(int) noexcept
: val(10) : val(10)
, const_val(15) , const_val(15)
, mdarray{} { , mdarray{} {
} }
TestBaseType(int *) TestBaseType(int *) noexcept
: val(10) : val(10)
, const_val(15) , const_val(15)
, mdarray{} { , mdarray{} {
} }
TestBaseType(const TestBaseType &other) TestBaseType(const TestBaseType &other) noexcept
: val(other.val) : val(other.val)
, const_val(other.const_val) , const_val(other.const_val)
, const_val_ptr(&const_val) , const_val_ptr(&const_val)
, func_member(other.func_member) { , func_member(other.func_member) {
} }
TestBaseType(TestBaseType &&other) TestBaseType(TestBaseType &&other) noexcept
: val(other.val) : val(other.val)
, const_val(other.const_val) , const_val(other.const_val)
, const_val_ptr(&const_val) , const_val_ptr(&const_val)
@ -59,7 +59,7 @@ public:
class Type2 { class Type2 {
public: public:
Type2(TestBaseType t_bt) Type2(TestBaseType t_bt) noexcept
: m_bt(std::move(t_bt)) : m_bt(std::move(t_bt))
, m_str("Hello World") { , m_str("Hello World") {
} }