tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
is_swappable_with.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_TYPE_TRAITS_IS_SWAPPABLE_WITH_HPP
4#define TETL_TYPE_TRAITS_IS_SWAPPABLE_WITH_HPP
5
16
17namespace etl {
18
19template <typename T>
20struct is_swappable;
21
22template <typename T>
24
25template <typename T>
27constexpr auto swap(T& a, T& b)
29
30template <typename T, etl::size_t N>
31 requires(etl::is_swappable<T>::value)
32constexpr auto swap(T (&a)[N], T (&b)[N]) noexcept(etl::is_nothrow_swappable<T>::value) -> void;
33
34// swap(declval<T>(), declval<U>()) is not valid
35template <typename T, typename U, typename = void>
36struct _swappable_with_helper : false_type { }; // NOLINT
37
38// swap(declval<T>(), declval<U>()) is valid
39template <typename T, typename U>
40struct _swappable_with_helper<T, U, void_t<decltype(swap(declval<T>(), declval<U>()))>> : true_type { }; // NOLINT
41
42// Determine if expressions with type and value category T and U can be
43// swapped (and vice versa)
44template <typename T, typename U>
45struct is_swappable_with : bool_constant<conjunction_v<_swappable_with_helper<T, U>, _swappable_with_helper<U, T>>> { };
46
47template <typename T, typename U>
49
50} // namespace etl
51
52#endif // TETL_TYPE_TRAITS_IS_SWAPPABLE_WITH_HPP
void void_t
Definition void_t.hpp:10
Definition adjacent_find.hpp:8
auto declval() noexcept -> add_rvalue_reference_t< T >
constexpr bool is_nothrow_move_constructible_v
Definition is_nothrow_move_constructible.hpp:20
constexpr bool is_move_constructible_v
Definition is_move_constructible.hpp:20
bool_constant< true > true_type
Definition bool_constant.hpp:13
auto swap(inplace_function< R(Args...), Capacity, Alignment > &lhs, inplace_function< R(Args...), Capacity, Alignment > &rhs) noexcept -> void
Overloads the etl::swap algorithm for etl::inplace_function. Exchanges the state of lhs with that of ...
Definition inplace_function.hpp:249
constexpr bool is_swappable_with_v
Definition is_swappable_with.hpp:48
integral_constant< bool, B > bool_constant
Definition bool_constant.hpp:11
bool_constant< false > false_type
Definition bool_constant.hpp:14
constexpr bool is_nothrow_move_assignable_v
Definition is_nothrow_move_assignable.hpp:28
constexpr bool is_move_assignable_v
Definition is_move_assignable.hpp:29
Definition is_swappable_with.hpp:36
static constexpr bool value
Definition integral_constant.hpp:10
If T is not a referenceable type (i.e., possibly cv-qualified void or a function type with a cv-quali...
Definition is_nothrow_swappable.hpp:16
Definition is_swappable_with.hpp:45
If T is not a referenceable type (i.e., possibly cv-qualified void or a function type with a cv-quali...
Definition is_swappable.hpp:16