Это та же самая ситуация для std::is_literal_type
и std::is_standard_layout
.
Реализация std::is_literal_type
в libc ++ равна
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_literal_type
#ifdef _LIBCPP_IS_LITERAL
: public integral_constant<bool, _LIBCPP_IS_LITERAL(_Tp)>
#else
: integral_constant<bool, is_scalar<typename remove_all_extents<_Tp>::type>::value ||
is_reference<typename remove_all_extents<_Tp>::type>::value>
#endif
{};
Нет _LIBCPP_IS_LITERAL
, поэтомукод будет
template <typename T> struct is_literal_type : integral_constant<bool,
is_scalar<typename remove_all_extents<T>::type>::value or
is_reference<typename remove_all_extents<T>::type>::value> {};
Я написал демо:
#include <iostream>
using namespace std;
struct s {
int a;
char b;
long c;
};
int main(int argc, char *argv[]) {
cout << boolalpha;
cout << is_scalar_v<typename remove_all_extents<s>::type> << endl;
cout << is_reference_v<typename remove_all_extents<s>::type> << endl;
}
Результат - false
и false
.Но результат is_literal_type_v<s>
равен true
.
Может кто-нибудь объяснить, как работает std::is_literal_type
?