Added new ctor to asset::SAssetBunlde
MODIFY
include/irr/asset/IAsset.h
include/irr/asset/IAsset.h
#include "irr/core/Types.h"
#include "irr/core/refctd_dynamic_array.h"
-namespace irr { namespace asset
+namespace irr {
+ namespace asset
{
class IAssetManager;
@@ -101,17 +102,13 @@ class SAssetBundle
public:
SAssetBundle(std::initializer_list<core::smart_refctd_ptr<IAsset>> _contents = {}) : m_contents(new contents_container_t(_contents), core::dont_grab)
{
- auto allSameTypeAndNotNull = [&_contents] {
- if (_contents.size()==0ull)
- return true;
- if (!*_contents.begin())
- return false;
- IAsset::E_TYPE t = (*_contents.begin())->getAssetType();
- for (const auto& ast : _contents)
- if (!ast || ast->getAssetType() != t)
- return false;
- return true;
- };
+ assert(allSameTypeAndNotNull());
+ }
+
+ template<class container_t = core::vector<core::smart_refctd_ptr<IAsset>>>
+ SAssetBundle(container_t&& _contents) : m_contents(new contents_container_t(_contents.size(), nullptr), core::dont_grab)
+ {
+ std::move(_contents.begin(), _contents.end(), m_contents->begin());
assert(allSameTypeAndNotNull());
}
@@ -153,8 +150,22 @@ private:
std::string m_cacheKey;
bool m_isCached = false;
core::smart_refctd_ptr<contents_container_t> m_contents;
+
+ bool allSameTypeAndNotNull()
+ {
+ if (m_contents->size() == 0ull)
+ return true;
+ if (!*m_contents->begin())
+ return false;
+ IAsset::E_TYPE t = (*m_contents->begin())->getAssetType();
+ for (const auto& ast : *m_contents)
+ if (!ast || ast->getAssetType() != t)
+ return false;
+ return true;
+ }
};
-}}
+ }
+}
#endif // __IRR_I_ASSET_H_INCLUDED__
\ No newline at end of file

Added new ctor to asset::SAssetBunlde