mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-14 19:41:29 +07:00
add is_virtual_base_of trait
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
#include "meta_base/insert_or_assign.hpp"
|
||||
#include "meta_base/intrusive_ptr.hpp"
|
||||
#include "meta_base/is_in_place_type.hpp"
|
||||
#include "meta_base/is_virtual_base_of.hpp"
|
||||
#include "meta_base/memory_buffer.hpp"
|
||||
#include "meta_base/noncopyable.hpp"
|
||||
#include "meta_base/nonesuch.hpp"
|
||||
|
||||
41
headers/meta.hpp/meta_base/is_virtual_base_of.hpp
Normal file
41
headers/meta.hpp/meta_base/is_virtual_base_of.hpp
Normal file
@@ -0,0 +1,41 @@
|
||||
/*******************************************************************************
|
||||
* This file is part of the "https://github.com/blackmatov/meta.hpp"
|
||||
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||
* Copyright (C) 2021-2023, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base.hpp"
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
namespace impl
|
||||
{
|
||||
template < typename From, typename To >
|
||||
constexpr bool is_virtual_base_of_impl(...) noexcept {
|
||||
return false;
|
||||
}
|
||||
|
||||
template <
|
||||
typename From,
|
||||
typename To,
|
||||
decltype(static_cast<const volatile To*>(std::declval<const volatile From*>())) = nullptr >
|
||||
constexpr bool is_virtual_base_of_impl(int) noexcept {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
||||
template < typename Base, typename Derived >
|
||||
struct is_virtual_base_of : std::integral_constant<bool,
|
||||
std::is_base_of_v<Base, Derived> &&
|
||||
impl::is_virtual_base_of_impl<Derived, Base>(0) &&
|
||||
!impl::is_virtual_base_of_impl<Base, Derived>(0)> {};
|
||||
|
||||
// clang-format on
|
||||
|
||||
template < typename Base, typename Derived >
|
||||
inline constexpr bool is_virtual_base_of_v = is_virtual_base_of<Base, Derived>::value;
|
||||
}
|
||||
Reference in New Issue
Block a user