«typetraits» 태그된 질문

5
`is_base_of`는 어떻게 작동합니까?
다음 코드는 어떻게 작동합니까? typedef char (&yes)[1]; typedef char (&no)[2]; template <typename B, typename D> struct Host { operator B*() const; operator D*(); }; template <typename B, typename D> struct is_base_of { template <typename T> static yes check(D*, T); static no check(B*, int); static const bool value = sizeof(check(Host<B,D>(), int())) …



1
std :: is_constructible은 개인 생성자에 대해 일치하지 않는 값을 반환합니다
std::is_constructible개인 생성자 를 처리 하는 규칙은 무엇입니까 ? 다음 코드가 주어진다 : #include <iostream> class Class { private: Class() { } }; template <typename T> class Test { public: static void test() { std::cout //<< std::is_constructible<Class>::value << std::is_constructible<T>::value << std::endl; } }; int main() { Test<Class>::test(); } 이것은 프린트 0( …
13 c++  typetraits 

1
gcc의 is_nothrow_constructible 구현에 static_cast가 필요한 이유는 무엇입니까?
GCC 구현에서 가져온 type_traits이유는 static_cast무엇입니까? template <typename _Tp, typename... _Args> struct __is_nt_constructible_impl : public integral_constant<bool, noexcept(_Tp(declval<_Args>()...))> {}; template <typename _Tp, typename _Arg> struct __is_nt_constructible_impl<_Tp, _Arg> : public integral_constant<bool, // Why is `static_cast` needed here? noexcept(static_cast<_Tp>(declval<_Arg>()))> {};

3
다음과 같은 경우 종속 유형에 typename을 사용할 필요가없는 이유는 무엇입니까?
유형의 참조를 제거하는 방법에 대해 읽었 습니다 . 다음 예제를 제공합니다. #include <iostream> // std::cout #include <type_traits> // std::is_same template<class T1, class T2> void print_is_same() { std::cout << std::is_same<T1, T2>() << '\n'; } int main() { std::cout << std::boolalpha; print_is_same<int, int>(); print_is_same<int, int &>(); print_is_same<int, int &&>(); print_is_same<int, std::remove_reference<int>::type>(); // …
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.