mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-28 13:57:22 +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>
|
||||
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...);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user