나는 다음과 같은 클래스 템플릿이 있습니다부분 템플릿 전문 SFINAE
template<bool head, bool... tail>
struct var_and {
static constexpr bool value = head && var_and<tail...>::value;
};
template<bool b> struct var_and<b> {
static constexpr bool value = b;
};
template<typename... Ts>
struct type_list {};
template <typename T, typename Enable = void>
class foo;
template <typename... T>
class foo<type_list<T...>, std::enable_if_t<var_and<std::is_integral_v<T>...>::value>> {};
나는 전문성과 일치하도록 시도해보십시오에서
Error C2079 'test' uses undefined class 'ECS::foo<ECS::type_list<int,int,int>,void>'
: 나는 오류가
foo<type_list<int, int, int>> test{};
을 같은 오류가 발생하는 경우 :
more than one partial specialization matches the template argument list of class "ECS::foo<ECS::type_list<int, int, int>, void>"
"ECS::foo<ECS::type_list<T...>, std::enable_if_t<ECS::var_and<std::is_integral_v<T>...>::value, void>>"
"ECS::foo<ECS::type_list<T...>, std::enable_if_t<ECS::var_and<std::is_integral_v<T>...>::value, void>>"
... (The exact same error message 6 more times)
SFINAE를 사용하여 variadic 유형 팩에서 유형의 유형 특성을 구체적으로 적용하려면 어떻게해야합니까?
나는 그것이 하나의 형식 인수를 위해 일을 점점 더 문제가 없었다 : 나는 단순히 static_assert을 사용할 수 있습니다 알고 http://www.cppsamples.com/common-tasks/class-template-sfinae.html,하지만하지 않고는 수도 있는지 궁금했다. 로 볼 수
을 당신이 MSVC를 사용하는 것 컴파일러의 출력에서. 이 코드는 gcc와 clang에서 완벽하게 작동합니다 (http://coliru.stacked-crooked.com/a/36b9eecd91763aaf 참조). 따라서 msvc 버그? 어느 쪽이든, 또는 우리 모두 컴파일 된 코드를주지 않았다. – Rerito
msvc로 컴파일 된이 정확한 코드는 http://rextester.com/NIU85113과 같은 오류를 준다. 그래서 나는 그것이 버그라고 가정하고 있나? –
사실 링크가 약간 다른 오류를 보여줍니다. http://webcompiler.cloudapp.net/에서 실행 된 동일한 코드가 동일한 오류를 발생시키고 더 최근의 컴파일러를 사용합니다. –