/* Copyright (C) 2015 * swift project Community / Contributors * * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, * including this file, may be copied, modified, propagated, or distributed except according to the terms * contained in the LICENSE file. */ //! \file #ifndef BLACKMISC_INHERITANCE_TRAITS_H #define BLACKMISC_INHERITANCE_TRAITS_H #include "typetraits.h" #include #include namespace BlackMisc { class CPropertyIndex; /*! * If T has a member typedef base_type, this trait will obtain it, otherwise void. */ template > struct TBaseOf { using type = void; //!< void }; //! \cond template struct TBaseOf> { using type = typename T::base_type; //!< T::base_type }; //! \endcond /*! * It T has a member typedef base_type which is a registered metatype, this trait will obtain it, otherwise void. */ template struct TMetaBaseOf { //! Type of T::base_type, or void if not declared. using type = std::conditional_t::type>::Defined, typename TBaseOf::type, void>; }; /*! * If T has a member typedef base_type which has a member propertyByIndex, this trait will obtain it, otherwise void. */ template > struct TIndexBaseOf { using type = void; //!< void }; //! \cond template struct TIndexBaseOf().propertyByIndex(std::declval()))>> { using type = typename T::base_type; //!< T::base_type }; //! \endcond /*! * Alias for typename TBaseOf::type. */ template using TBaseOfT = typename TBaseOf::type; /*! * Alias for typename TMetaBaseOf::type. */ template using TMetaBaseOfT = typename TMetaBaseOf::type; /*! * Alias for typename TIndexBaseOf::type. */ template using TIndexBaseOfT = typename TIndexBaseOf::type; } #endif