mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-29 06:15:24 +00:00
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:
parent
970afbe517
commit
8badffee79
@ -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...);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user