From f03c765b11d8125376830c3734fe2271c08b8659 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 26 Oct 2020 19:58:07 +0000 Subject: Simplify GetTypeId without enable_if --- slicer/slicer/modelPartsTypes.h | 6 ------ slicer/slicer/modelPartsTypes.impl.h | 29 ++++++++++------------------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/slicer/slicer/modelPartsTypes.h b/slicer/slicer/modelPartsTypes.h index f9c76d4..9cc8ac9 100644 --- a/slicer/slicer/modelPartsTypes.h +++ b/slicer/slicer/modelPartsTypes.h @@ -177,12 +177,6 @@ namespace Slicer { [[nodiscard]] bool HasValue() const override; [[nodiscard]] TypeId GetTypeId() const override; - template - const std::string & getTypeId( - typename std::enable_if::value>::type * = nullptr) const; - template - std::string getTypeId( - typename std::enable_if::value>::type * = nullptr) const; [[nodiscard]] std::optional GetTypeIdProperty() const override; diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h index cb24fe4..af3f980 100644 --- a/slicer/slicer/modelPartsTypes.impl.h +++ b/slicer/slicer/modelPartsTypes.impl.h @@ -564,25 +564,16 @@ namespace Slicer { { BOOST_ASSERT(this->Model); BOOST_ASSERT(className); - return ModelPartForComplexBase::GetTypeId(getTypeId(), *className); - } - - template - template - const std::string & - ModelPartForClass::getTypeId(typename std::enable_if::value>::type *) const - { - BOOST_ASSERT(this->Model); - return (*this->Model)->ice_id(); - } - - template - template - std::string - ModelPartForClass::getTypeId(typename std::enable_if::value>::type *) const - { - BOOST_ASSERT(this->Model); - return ModelPartForComplexBase::demangle(typeid(*this->Model->get()).name()); + return ModelPartForComplexBase::GetTypeId( + [this]() { + if constexpr (std::is_base_of_v) { + return (*this->Model)->ice_id(); + } + else { + return ModelPartForComplexBase::demangle(typeid(*this->Model->get()).name()); + } + }(), + *className); } // ModelPartForStruct -- cgit v1.2.3