I found that STL uses declval<T &>
in implementation of std::is_destructible
:
template <class>
struct __is_destructible_apply { typedef int type; };
template <typename _Tp>
struct __is_destructor_wellformed {
template <typename _Tp1>
static char __test (
typename __is_destructible_apply<decltype(_VSTD::declval<_Tp1&>().~_Tp1())>::type
);
template <typename _Tp1>
static __two __test (...);
static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char);
};
It's my implementation :
template <typename T>
select_second_type_t<decltype(declval<T /* difference from STL */>().~T()), true_type>
test_destructible(int) noexcept;
template <typename> false_type test_destructible(...) noexcept;
template <typename T>
struct my_is_destructible : conditional_t<
not is_function_v<T> and not is_unbounded_array_v<T> and not is_same_v<void, T> and is_complete_v<T>,
conditional_t<
is_reference_v<T>,
true_type,
decltype(__dsa::test_destructible<remove_extents_t<T>>(0))
>,
false_type
> {};
I haven't noticed any difference, why STL implements std::is_destructible
as declval<T &>
instead of declval<T>
. I provided various T
, but all returning value of std::is_destructible<T>
is same as my_is_destructible
Aucun commentaire:
Enregistrer un commentaire