Lua-API++
2015-02-12-3
Lua-API++ library
|
Valset is an STL-compatible container for contiguous Lua stack slots. Its primary use is accepting multiple return values. More...
Inherits noNew.
Public Types | |
typedef Valref | value_type |
The Valref objects are not actually stored, but rather created dynamically. | |
typedef size_t | size_type |
Index type. | |
typedef ptrdiff_t | difference_type |
Index difference. | |
typedef valset_iterator | iterator |
Normal iterator. | |
typedef valset_const_iterator | const_iterator |
Const iterator. | |
typedef std::reverse_iterator< iterator > | reverse_iterator |
Reverse iterator. | |
typedef std::reverse_iterator< const_iterator > | const_reverse_iterator |
Reverse const iterator. | |
typedef value_type | reference |
Reference to a value is still a Valref. | |
typedef const value_type | const_reference |
Const reference doesn't strictly enforce immutability. | |
Public Member Functions | |
Life cycle | |
Valset (Temporary src) | |
Construct from an expression. More... | |
Valset (const Valref &src) | |
Copy a value into set (works with Value and Table too). | |
Valset (Valset &&) | |
Valset can be returned from functions but not actually moved. | |
Valset (Context &s) noexcept | |
Create an empty Valset. More... | |
Valset (const Valset &src) noexcept | |
Create copies of values stored in src. | |
~Valset () noexcept | |
Owned stack slots are freed on destruction. | |
Element access | |
reference | at (size_t index) |
Checked indexation. More... | |
const_reference | at (size_t index) const |
Checked indexation. More... | |
const_reference | operator[] (size_t index) const noexcept |
Unchecked indexation. | |
reference | operator[] (size_t index) noexcept |
Unchecked indexation. | |
Iterators | |
iterator | begin () noexcept |
const_iterator | begin () const noexcept |
const_iterator | cbegin () const noexcept |
iterator | end () noexcept |
const_iterator | end () const noexcept |
const_iterator | cend () const noexcept |
reverse_iterator | rbegin () noexcept |
const_reverse_iterator | rbegin () const noexcept |
const_reverse_iterator | crbegin () const noexcept |
reverse_iterator | rend () noexcept |
const_reverse_iterator | rend () const noexcept |
const_reverse_iterator | crend () const noexcept |
Capacity | |
size_t | size () const noexcept |
Amount of stored values. | |
bool | empty () const noexcept |
Check if the container is empty. | |
Modification | |
template<typename... Types> | |
void | push_back (Types &&...values) |
Add values to the end. More... | |
void | pop_back (size_t amount=1) |
Remove a value from the end. More... | |
Status query | |
bool | success () const noexcept |
Protected call status. More... | |
bool | isBlocked () const noexcept |
Blocked status. More... | |
Valset is an STL-compatible container for contiguous Lua stack slots. Its primary use is accepting multiple return values.
This object owns arbitrary number of neighbouring stack slots. It is STL compatible, so it's possible to use standard algorithms with it (also things like back_inserter, range-based for and so on). The values are accessed by indexation with integer indices or through iterators which dereference to Valref.
This class is designed for following uses:
If no values are placed on the stack after the Valset, it is unblocked, which means that new value can be added to its end with push_back, or the last value be removed with pop_back function. Otherwise the Valset is in "blocked" state and cannot be grown or shrunk.
On object's destruction all owned slots are freed (unless it is used to return values from the function).
When put inside value sequence (like function arguments or array content), Valset automatically expands into contained values. But Valset cannot be used in a place that requires single value (like index).
Construct from an expression.
The created Valset will have 1 element inside.
If the expression was a function call that returned multiple values, the Valset will contain all returned values.
If the expression was a protected function call which ended succesfully, the Valset will contain all returned values.
Unsuccesfull protected call will put into Valset error description and the success status will be "false".
|
inline |
Checked indexation.
std::range | error |
|
inline |
Checked indexation.
std::range | error |
void push_back | ( | Types &&... | values | ) |
void pop_back | ( | size_t | amount = 1 | ) |
|
inlinenoexcept |