tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
is_base_of.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_TYPE_TRAITS_IS_BASE_OF_HPP
5#define TETL_TYPE_TRAITS_IS_BASE_OF_HPP
6
7#include <etl/_type_traits/bool_constant.hpp>
8#include <etl/_type_traits/is_class.hpp>
9
10namespace etl {
11
12namespace detail {
13template <typename B>
14auto test_pre_ptr_convertible(B const volatile*) -> true_type;
15template <typename>
16auto test_pre_ptr_convertible(void const volatile*) -> false_type;
17
18template <typename, typename>
19auto test_pre_is_base_of(...) -> true_type;
20template <typename B, typename D>
21auto test_pre_is_base_of(int) -> decltype(test_pre_ptr_convertible<B>(static_cast<D*>(nullptr)));
22} // namespace detail
23
24/// \brief If Derived is derived from Base or if both are the same non-union
25/// class (in both cases ignoring cv-qualification), provides the member
26/// constant value equal to true. Otherwise value is false.
27///
28/// \details If both Base and Derived are non-union class types, and they are
29/// not the same type (ignoring cv-qualification), Derived shall be a complete
30/// type; otherwise the behavior is undefined.
31///
32/// https://en.cppreference.com/w/cpp/types/is_base_of
33///
34/// \ingroup type_traits
35template <typename Base, typename Derived>
37 : bool_constant<
38 is_class_v<Base> and is_class_v<Derived>and decltype(detail::test_pre_is_base_of<Base, Derived>(0))::value
39 > { };
40
41/// \relates is_base_of
42/// \ingroup type_traits
43template <typename Base, typename Derived>
44inline constexpr bool is_base_of_v = is_base_of<Base, Derived>::value;
45
46} // namespace etl
47
48#endif // TETL_TYPE_TRAITS_IS_BASE_OF_HPP
constexpr bool is_base_of_v
Definition is_base_of.hpp:44
Definition adjacent_find.hpp:9
If Derived is derived from Base or if both are the same non-union class (in both cases ignoring cv-qu...
Definition is_base_of.hpp:39