diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2020-10-26 19:58:07 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2020-10-26 19:58:07 +0000 |
commit | f03c765b11d8125376830c3734fe2271c08b8659 (patch) | |
tree | eacd5c42e9501c55a4f657b31dbc3e0435644f10 | |
parent | string_view child ref uplooks (diff) | |
download | slicer-f03c765b11d8125376830c3734fe2271c08b8659.tar.bz2 slicer-f03c765b11d8125376830c3734fe2271c08b8659.tar.xz slicer-f03c765b11d8125376830c3734fe2271c08b8659.zip |
Simplify GetTypeId without enable_if
-rw-r--r-- | slicer/slicer/modelPartsTypes.h | 6 | ||||
-rw-r--r-- | 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<typename dummy = T> - const std::string & getTypeId( - typename std::enable_if<std::is_base_of<Ice::Object, dummy>::value>::type * = nullptr) const; - template<typename dummy = T> - std::string getTypeId( - typename std::enable_if<!std::is_base_of<Ice::Object, dummy>::value>::type * = nullptr) const; [[nodiscard]] std::optional<std::string> 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<typename T> - template<typename dummy> - const std::string & - ModelPartForClass<T>::getTypeId(typename std::enable_if<std::is_base_of<Ice::Object, dummy>::value>::type *) const - { - BOOST_ASSERT(this->Model); - return (*this->Model)->ice_id(); - } - - template<typename T> - template<typename dummy> - std::string - ModelPartForClass<T>::getTypeId(typename std::enable_if<!std::is_base_of<Ice::Object, dummy>::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<Ice::Object, T>) { + return (*this->Model)->ice_id(); + } + else { + return ModelPartForComplexBase::demangle(typeid(*this->Model->get()).name()); + } + }(), + *className); } // ModelPartForStruct |