tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
is_nothrow_constructible.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_HPP
4#define TETL_TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_HPP
5
6#include <etl/_config/all.hpp>
7
11
12namespace etl {
13
14namespace detail {
15template <bool, typename T, typename... Args>
16struct nothrow_constructible_impl : false_type { };
17
18template <typename T, typename... Args>
19struct nothrow_constructible_impl<true, T, Args...> : bool_constant<noexcept(T(declval<Args>()...))> { };
20
21template <typename T, typename Arg>
22struct nothrow_constructible_impl<true, T, Arg> : bool_constant<noexcept(static_cast<T>(declval<Arg>()))> { };
23
24template <typename T>
25struct nothrow_constructible_impl<true, T> : bool_constant<noexcept(T())> { };
26
27template <typename T, size_t Size>
28struct nothrow_constructible_impl<true, T[Size]> : bool_constant<noexcept(remove_all_extents_t<T>())> { };
29
30#if defined(__cpp_aggregate_paren_init)
31template <typename T, size_t Size, typename Arg>
32struct nothrow_constructible_impl<true, T[Size], Arg> : nothrow_constructible_impl<true, T, Arg> { };
33
34template <typename T, size_t Size, typename... Args>
35struct nothrow_constructible_impl<true, T[Size], Args...>
36 : bool_constant<(nothrow_constructible_impl<true, T, Args>::value && ...)> { };
37#endif
38
39template <typename T, typename... Args>
40using is_nothrow_constructible_helper = nothrow_constructible_impl<__is_constructible(T, Args...), T, Args...>;
41} // namespace detail
42
46template <typename T, typename... Args>
47struct is_nothrow_constructible : detail::is_nothrow_constructible_helper<T, Args...>::type { };
48
49template <typename T, typename... Args>
50inline constexpr bool is_nothrow_constructible_v = is_nothrow_constructible<T, Args...>::value;
51
52} // namespace etl
53
54#endif // TETL_TYPE_TRAITS_IS_NOTHROW_CONSTRUCTIBLE_HPP
Definition adjacent_find.hpp:8
constexpr bool is_nothrow_constructible_v
Definition is_nothrow_constructible.hpp:50
integral_constant< bool, B > bool_constant
Definition bool_constant.hpp:11
bool_constant< false > false_type
Definition bool_constant.hpp:14
integral_constant< Type, Val > type
Definition integral_constant.hpp:12
The variable definition does not call any operation that is not trivial. For the purposes of this che...
Definition is_nothrow_constructible.hpp:47