From b97aef14dac67aeaf526dcf932db2f7fbdcf9424 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 21 Aug 2012 11:23:10 +0200 Subject: [PATCH] Fix constructing for mixed cases of EbmlMaster and other types --- tests/unit/construct.h | 54 ++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/tests/unit/construct.h b/tests/unit/construct.h index 45acdecea..60514306a 100644 --- a/tests/unit/construct.h +++ b/tests/unit/construct.h @@ -16,6 +16,9 @@ #include "common/common_pch.h" +#include +#include + #include #include #include @@ -30,66 +33,64 @@ using namespace libebml; template -typename boost::enable_if< boost::is_base_of >::type +typename boost::enable_if< std::is_base_of >::type cons_impl(EbmlMaster *master, Tobject *object, - Tvalue &&value) { + Tvalue const &value) { *static_cast(object) = value; master->PushElement(*object); } template -typename boost::enable_if< boost::is_base_of >::type +typename boost::enable_if< std::is_base_of >::type cons_impl(EbmlMaster *master, Tobject *object, - Tvalue &&value) { + Tvalue const &value) { *static_cast(object) = value; master->PushElement(*object); } template -typename boost::enable_if< boost::is_base_of >::type +typename boost::enable_if< std::is_base_of >::type cons_impl(EbmlMaster *master, Tobject *object, - Tvalue &&value) { + Tvalue const &value) { *static_cast(object) = value; master->PushElement(*object); } template -typename boost::enable_if< boost::is_base_of >::type +typename boost::enable_if< std::is_base_of >::type cons_impl(EbmlMaster *master, Tobject *object, - Tvalue &&value) { + Tvalue const &value) { *static_cast(object) = value; master->PushElement(*object); } template -typename boost::enable_if< boost::is_base_of >::type +typename boost::enable_if< std::is_base_of >::type cons_impl(EbmlMaster *master, Tobject *object, - Tvalue &&value) { + Tvalue const &value) { *static_cast(object) = value; master->PushElement(*object); } -template -typename boost::enable_if< boost::is_base_of >::type +void cons_impl(EbmlMaster *master, - Tsub_master *sub_master) { + EbmlMaster *sub_master) { master->PushElement(*sub_master); } -template -typename boost::enable_if< boost::is_base_of >::type +template +void cons_impl(EbmlMaster *master, - Tsub_master *sub_master, + EbmlMaster *sub_master, Targs... args) { master->PushElement(*sub_master); cons_impl(master, args...); @@ -98,22 +99,29 @@ cons_impl(EbmlMaster *master, template -void +typename boost::disable_if< std::is_convertible >::type cons_impl(EbmlMaster *master, Tobject *object, - Tvalue &&value, + Tvalue const &value, Targs... args) { cons_impl(master, object, value); cons_impl(master, args...); } -template -Tmaster * -cons(Targs... args) { +template +EbmlMaster * +cons() { auto master = new Tmaster; master->RemoveAll(); + return master; +} + +template +EbmlMaster * +cons(Targs... args) { + auto master = cons(); cons_impl(master, args...); return master;