Skip to content

Commit

Permalink
#verification #sonar #docs
Browse files Browse the repository at this point in the history
  • Loading branch information
serges147 committed Sep 26, 2024
1 parent 1d83788 commit 139662c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 4 additions & 0 deletions cetlvast/suites/unittest/test_type_traits_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ static_assert(best_conversion_index_v<universal_predicate, std::uint64_t, foo, s
static_assert(best_conversion_index_v<universal_predicate, std::uint64_t, foo, std::int8_t> == 1, "");
static_assert(best_conversion_index_v<universal_predicate, std::uint64_t, foo> == 0, "");

// clang-format off

static_assert(best_conversion_index_v<partial<is_convertible_without_narrowing, std::uint8_t>::template type, std::uint8_t, foo, std::uint64_t> == 1, "");
static_assert(best_conversion_index_v<partial<is_convertible_without_narrowing, std::uint8_t>::template type, std::uint8_t, foo, std::uint32_t> == 1, "");
static_assert(best_conversion_index_v<partial<is_convertible_without_narrowing, std::uint8_t>::template type, std::uint8_t, foo, std::uint16_t> == 1, "");
Expand Down Expand Up @@ -179,6 +181,8 @@ static_assert(best_conversion_index_v<partial<is_convertible_without_narrowing,
static_assert(best_conversion_index_v<partial<is_convertible_without_narrowing, std::uint32_t>::template type, std::uint32_t, foo, std::int8_t> == bad, "");
static_assert(best_conversion_index_v<partial<is_convertible_without_narrowing, std::uint32_t>::template type, std::uint32_t, foo> == bad, "");

// clang-format on

} // namespace test_best_conversion_index

// NOLINTEND(*-explicit-constructor)
14 changes: 6 additions & 8 deletions include/cetl/type_traits_ext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ struct partial
namespace detail
{
enum narrowing_detector_tag
{};
{
};
template <typename T>
struct narrowing_detector
{
Expand All @@ -127,12 +128,8 @@ template <typename From, typename To>
struct is_convertible_without_narrowing<
From,
To,
void_t<decltype(detail::narrowing_detector<To>
{
std::declval<detail::narrowing_detector_tag>(),
{std::declval<From>(), std::declval<From>()}
})>
> : std::true_type
void_t<decltype(detail::narrowing_detector<To>{std::declval<detail::narrowing_detector_tag>(),
{std::declval<From>(), std::declval<From>()}})>> : std::true_type
{};
static_assert(is_convertible_without_narrowing<std::uint32_t, std::uint64_t>::value, "self-test failure");
static_assert(!is_convertible_without_narrowing<std::uint64_t, std::uint32_t>::value, "self-test failure");
Expand Down Expand Up @@ -200,7 +197,8 @@ struct impl : std::integral_constant<std::size_t, std::numeric_limits<std::size_
{};
template <template <typename...> class Q, typename F, typename... Ts>
struct impl<Q, F, types<Ts...>, void_t<decltype(resolver<Q, sizeof...(Ts) - 1U, Ts...>::match(std::declval<F>()))>>
: decltype(resolver<Q, sizeof...(Ts) - 1U, Ts...>::match(std::declval<F>())){};
: decltype(resolver<Q, sizeof...(Ts) - 1U, Ts...>::match(std::declval<F>()))
{};
} // namespace best_conversion_index
} // namespace detail

Expand Down

0 comments on commit 139662c

Please sign in to comment.