tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
is_destructible.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_TYPE_TRAITS_IS_DESTRUCTIBLE_HPP
4#define TETL_TYPE_TRAITS_IS_DESTRUCTIBLE_HPP
5
17
18namespace etl {
19
20namespace detail {
21
22struct try_is_destructible_impl {
23 template <typename T, typename = decltype(etl::declval<T&>().~T())>
24 static auto test(int) -> etl::true_type;
25
26 template <typename>
27 static auto test(...) -> etl::false_type;
28};
29
30template <typename T>
31struct is_destructible_impl : try_is_destructible_impl {
32 using type = decltype(test<T>(0));
33};
34
35template <
36 typename T,
37 bool = etl::disjunction<etl::is_void<T>, etl::is_function<T>, etl::is_unbounded_array<T>>::value,
38 bool = etl::disjunction<etl::is_reference<T>, etl::is_scalar<T>>::value>
39struct is_destructible_safe;
40
41template <typename T>
42struct is_destructible_safe<T, false, false> : is_destructible_impl<typename etl::remove_all_extents_t<T>>::type { };
43
44template <typename T>
45struct is_destructible_safe<T, true, false> : etl::false_type { };
46
47template <typename T>
48struct is_destructible_safe<T, false, true> : etl::true_type { };
49
50} // namespace detail
51
59template <typename T>
60struct is_destructible : detail::is_destructible_safe<T> { };
61
62template <typename Type>
63struct is_destructible<Type[]> : false_type { };
64
65template <>
66struct is_destructible<void> : false_type { };
67
68template <typename T>
70
71} // namespace etl
72
73#endif // TETL_TYPE_TRAITS_IS_DESTRUCTIBLE_HPP
Definition adjacent_find.hpp:8
bool_constant< true > true_type
Definition bool_constant.hpp:13
bool_constant< false > false_type
Definition bool_constant.hpp:14
constexpr auto is_destructible_v
Definition is_destructible.hpp:69
Because the C++ program terminates if a destructor throws an exception during stack unwinding (which ...
Definition is_destructible.hpp:60