refactor(furvm): add shared pointer aliases
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
#include "furvm/fwd.hpp"
|
||||
#include "furvm/module.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
@@ -48,7 +47,7 @@ public:
|
||||
* @param index Index to the module.
|
||||
* @return Old value.
|
||||
*/
|
||||
std::shared_ptr<mod> erase(module_handle index) {
|
||||
mod_p erase(module_handle index) {
|
||||
if (index >= m_modules.size()) return nullptr;
|
||||
return std::move(m_modules[index]);
|
||||
}
|
||||
@@ -59,7 +58,7 @@ public:
|
||||
* @param index Position of the module.
|
||||
* @return The module.
|
||||
*/
|
||||
constexpr std::shared_ptr<mod>& operator[](module_handle index) { return m_modules[index]; }
|
||||
constexpr mod_p& operator[](module_handle index) { return m_modules[index]; }
|
||||
|
||||
/**
|
||||
* @brief Returns a module of this context.
|
||||
@@ -67,7 +66,7 @@ public:
|
||||
* @param index Position of the module.
|
||||
* @return The module.
|
||||
*/
|
||||
constexpr const std::shared_ptr<mod>& operator[](module_handle index) const { return m_modules[index]; }
|
||||
constexpr const mod_p& operator[](module_handle index) const { return m_modules[index]; }
|
||||
|
||||
/**
|
||||
* @brief Returns a module of this context.
|
||||
@@ -75,7 +74,7 @@ public:
|
||||
* @param index Position of the module.
|
||||
* @return The module.
|
||||
*/
|
||||
constexpr std::shared_ptr<mod>& at(module_handle index) { return m_modules.at(index); }
|
||||
constexpr mod_p& at(module_handle index) { return m_modules.at(index); }
|
||||
|
||||
/**
|
||||
* @brief Returns a module of this context.
|
||||
@@ -83,7 +82,7 @@ public:
|
||||
* @param index Position of the module.
|
||||
* @return The module.
|
||||
*/
|
||||
constexpr const std::shared_ptr<mod>& at(module_handle index) const { return m_modules.at(index); }
|
||||
constexpr const mod_p& at(module_handle index) const { return m_modules.at(index); }
|
||||
|
||||
/**
|
||||
* @brief Returns how many does this context have modules.
|
||||
@@ -92,9 +91,9 @@ public:
|
||||
*/
|
||||
constexpr size_t size() const { return m_modules.size(); }
|
||||
private:
|
||||
std::vector<std::shared_ptr<mod>> m_modules;
|
||||
std::vector<std::shared_ptr<thing>> m_things;
|
||||
std::vector<std::shared_ptr<executor>> m_executors;
|
||||
std::vector<mod_p> m_modules;
|
||||
std::vector<thing_p> m_things;
|
||||
std::vector<executor_p> m_executors;
|
||||
};
|
||||
|
||||
} // namespace furvm
|
||||
|
||||
Reference in New Issue
Block a user