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