tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
is_empty.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_EMPTY_HPP
5#define TETL_TYPE_TRAITS_IS_EMPTY_HPP
6
7#include <etl/_type_traits/bool_constant.hpp>
8#include <etl/_type_traits/is_class.hpp>
9#include <etl/_type_traits/remove_cv.hpp>
10
11namespace etl {
12
13namespace detail {
14
15template <typename T>
16struct is_empty_tester_1 : etl::remove_cv_t<T> {
17 char dummy_data;
18};
19
20struct is_empty_tester_2 {
21 char dummy_data;
22};
23
24template <typename T>
25struct is_empty : false_type { };
26
27template <typename T>
28 requires is_class_v<T>
29struct is_empty<T> : bool_constant<sizeof(is_empty_tester_1<T>) == sizeof(is_empty_tester_2)> { };
30
31} // namespace detail
32
33/// \brief f T is an empty type (that is, a non-union class type with no
34/// non-static data members other than bit-fields of size 0, no virtual
35/// functions, no virtual base classes, and no non-empty base classes), provides
36/// the member constant value equal to true. For any other type, value is false.
37template <typename T>
38struct is_empty : detail::is_empty<T> { };
39
40template <typename T>
41inline constexpr bool is_empty_v = is_empty<T>::value;
42
43} // namespace etl
44
45#endif // TETL_TYPE_TRAITS_IS_EMPTY_HPP
Definition adjacent_find.hpp:9
constexpr bool is_empty_v
Definition is_empty.hpp:41
f T is an empty type (that is, a non-union class type with no non-static data members other than bit-...
Definition is_empty.hpp:38