mirror of
https://github.com/ChaiScript/ChaiScript.git
synced 2025-12-07 17:26:55 +08:00
Fix issues with Function_Params constructors (array and vector args)
- code (on MSVC) was asserting due to trying to dereference invalid pointers (dereferencing the end iterator, even if only to get its address!). - when a Function_Params is constructed with an empty vector, you can't return the address of the vec.front() -- instead we use nullptr for the m_begin and m_end pointers.
This commit is contained in:
parent
27072a77e6
commit
dd69230f19
@ -30,13 +30,19 @@ namespace chaiscript {
|
||||
}
|
||||
|
||||
explicit Function_Params(const std::vector<Boxed_Value> &vec)
|
||||
: m_begin(&vec.front()), m_end(&vec.front() + vec.size())
|
||||
: m_begin(vec.empty() ? nullptr : &vec.front()), m_end(vec.empty() ? nullptr : &vec.front() + vec.size())
|
||||
{
|
||||
}
|
||||
|
||||
template<size_t Size>
|
||||
constexpr explicit Function_Params(const std::array<Boxed_Value, Size> &a)
|
||||
: m_begin(&*std::begin(a)), m_end(&*std::end(a))
|
||||
: m_begin(&a.front()), m_end(&a.front() + Size)
|
||||
{
|
||||
}
|
||||
|
||||
template<>
|
||||
constexpr explicit Function_Params(const std::array<Boxed_Value, size_t{0}> &a)
|
||||
: m_begin(nullptr), m_end(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user