tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
is_convertible.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_TYPE_TRAITS_IS_CONVERTIBLE_HPP
4#define TETL_TYPE_TRAITS_IS_CONVERTIBLE_HPP
5
9
10namespace etl {
11
12namespace detail {
13template <typename>
14using true_type_for = etl::true_type;
15
16template <typename T>
17auto test_returnable(int) -> true_type_for<T()>;
18template <typename>
19auto test_returnable(...) -> etl::false_type;
20
21template <typename From, typename To>
22auto test_nonvoid_convertible(int) -> true_type_for<decltype(etl::declval<void (&)(To)>()(etl::declval<From>()))>;
23template <typename, typename>
24auto test_nonvoid_convertible(...) -> etl::false_type;
25
26} // namespace detail
27
38template <typename From, typename To>
41 (decltype(detail::test_returnable<To>(0))::value
42 && decltype(detail::test_nonvoid_convertible<From, To>(0))::value)
43 || (is_void_v<From> && is_void_v<To>)> { };
44
45template <typename From, typename To>
47
48} // namespace etl
49
50#endif // TETL_TYPE_TRAITS_IS_CONVERTIBLE_HPP
Definition adjacent_find.hpp:8
auto declval() noexcept -> add_rvalue_reference_t< T >
bool_constant< true > true_type
Definition bool_constant.hpp:13
integral_constant< bool, B > bool_constant
Definition bool_constant.hpp:11
bool_constant< false > false_type
Definition bool_constant.hpp:14
constexpr bool is_convertible_v
Definition is_convertible.hpp:46
static constexpr bool value
Definition integral_constant.hpp:10
If the imaginary function definition To test() { return etl::declval<From>(); } is well-formed,...
Definition is_convertible.hpp:43