construct: change return type of cons() from EbmlMaster* to T*

There's really no need to use the generic parent type. Using the
template argument's type instead allows one to wrap the result into
shared pointers as in e.g.

KaxAttachedPtr
createAttachment() {
  // …
  return {
    mtx::construct::cons<KaxAttached>(new KaxFile, …)
  };
}
This commit is contained in:
Moritz Bunkus 2015-12-31 21:56:33 +01:00
parent 970afbe517
commit 8badffee79

View File

@ -139,9 +139,9 @@ cons_impl(EbmlMaster *master,
} }
template<typename T> template<typename T>
EbmlMaster * auto
master() { master() -> T * {
T *master = new T; auto *master = new T;
for (auto element : *master) for (auto element : *master)
delete element; delete element;
master->RemoveAll(); master->RemoveAll();
@ -149,15 +149,15 @@ master() {
} }
template<typename Tmaster> template<typename Tmaster>
inline EbmlMaster * inline auto
cons() { cons() -> Tmaster * {
return master<Tmaster>(); return master<Tmaster>();
} }
template<typename Tmaster, template<typename Tmaster,
typename... Targs> typename... Targs>
inline EbmlMaster * inline auto
cons(Targs... args) { cons(Targs... args) -> Tmaster * {
auto master = cons<Tmaster>(); auto master = cons<Tmaster>();
cons_impl(master, args...); cons_impl(master, args...);