12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #ifndef QLOW_UTIL_H
- #define QLOW_UTIL_H
- #include <vector>
- #include <memory>
- #include <sstream>
- #include <typeinfo>
- namespace qlow
- {
-
- template<typename T>
- using OwningList = std::vector<std::unique_ptr<T>>;
-
-
-
-
-
-
- template<typename T, typename U>
- std::unique_ptr<T> unique_dynamic_cast(std::unique_ptr<U>&& p)
- {
- U* released = p.release();
- if (T* casted = dynamic_cast<T*>(released); casted)
- return std::unique_ptr<T> (casted);
- else {
- delete released;
-
- throw std::string("invalid unique_dynamic_cast from ") + typeid(p.get()).name() + " to " + typeid(T).name();
- }
- }
-
- namespace util
- {
- inline std::string toString(const void* a)
- {
- std::ostringstream o;
- o << a;
- return o.str();
- }
- }
- }
- #endif // QLOW_UTIL_H
|