My Project
is_nothrow_convertible.hpp
Go to the documentation of this file.
1 
28 #ifndef BSL_IS_NOTHROW_CONVERTIBLE_HPP
29 #define BSL_IS_NOTHROW_CONVERTIBLE_HPP
30 
31 #include "bool_constant.hpp"
32 #include "declval.hpp"
33 #include "false_type.hpp"
34 #include "is_void.hpp"
35 #include "true_type.hpp"
36 
37 namespace bsl
38 {
39  namespace details
40  {
51  template<typename T>
52  auto test_is_nothrow_convertible1(bsl::int32 ignored) noexcept -> true_type_for<T()>;
53 
64  template<typename T>
65  auto test_is_nothrow_convertible1(bool ignored) noexcept -> false_type;
66 
80  template<typename From, typename To>
81  auto test_is_nothrow_convertible2(bsl::int32 ignored) noexcept -> bool_constant<
82  noexcept(declval<void (&)(To) noexcept>()(declval<From>()))>; // NOLINT
83 
97  template<typename From, typename To>
98  auto test_is_nothrow_convertible2(bool ignored) noexcept -> false_type;
99 
109  template<typename From, typename To>
110  [[nodiscard]] constexpr bool
112  {
113  if constexpr (is_void<From>::value && is_void<To>::value) {
114  return true;
115  }
116 
117  return decltype(test_is_nothrow_convertible2<From, To>(0))::value &&
118  decltype(test_is_nothrow_convertible1<To>(0))::value;
119  }
120  }
121 
134  template<typename From, typename To>
135  class is_nothrow_convertible final : // --
136  public bool_constant<details::check_is_nothrow_convertible<From, To>()>
137  {};
138 }
139 
140 #endif
integral_constant< bool, B > bool_constant
provides the boolean version of an integral constant
Definition: bool_constant.hpp:37
If the provided type is convertible from "From" to "To", provides the member constant value equal to ...
Definition: is_nothrow_convertible.hpp:135
true_type true_type_for
provides a bool_constant that represents "true"
Definition: true_type.hpp:40
If the provided type is a void type (taking into account const qualifications), provides the member c...
Definition: is_void.hpp:48
auto test_is_nothrow_convertible1(bsl::int32 ignored) noexcept -> true_type_for< T()>
Tests if the provided type is returnable, which is required for a type to be convertible....
If the provided type is an array type (taking into account const qualifications), provides the member...
Definition: integral_constant.hpp:45
::int32_t int32
defines an 32bit signed integer
Definition: cstdint.hpp:40
constexpr bool check_is_nothrow_convertible() noexcept
Performs all of the tests including testing if both types are void.
Definition: is_nothrow_convertible.hpp:111
auto test_is_nothrow_convertible2(bsl::int32 ignored) noexcept -> bool_constant< noexcept(declval< void(&)(To) noexcept >()(declval< From >()))>
Tests whether or not the provided to can be converted from "From" to "To" via a function parameter si...
bool_constant< false > false_type
provides a bool_constant that represents "false"
Definition: false_type.hpp:36