C++ 静态断言引用封闭模板类

C++ 静态断言引用封闭模板类,c++,c++11,c++14,c++17,variadic-templates,C++,C++11,C++14,C++17,Variadic Templates,在下面的代码中,VS2015在ISinstation::value处投诉,给出此错误“模板参数'TT'的模板参数无效,应为类模板”。我该如何着手解决这个问题?我想将OtherType限制在T1为witherSomeType或OtherType的情况下 template <template<typename...> class TT, typename T> struct IsInstantiation : std::false_type { }; template &l

在下面的代码中,VS2015在
ISinstation::value
处投诉,给出此错误“模板参数'TT'的模板参数无效,应为类模板”。我该如何着手解决这个问题?我想将
OtherType
限制在T1为wither
SomeType
OtherType
的情况下

template <template<typename...> class TT, typename T>
struct IsInstantiation : std::false_type
{
};

template <template<typename...> class TT, typename... Ts>
struct IsInstantiation<TT, TT<Ts...>> : std::true_type
{
};

template <typename T1>
class SomeType{};

template <typename T1, typename T2>
class OtherType
{
    static_assert(IsInstantiation<SomeType, T1>::value ||
        IsInstantiation<OtherType, T1>::value,
        "Event must have SomeType or OtherType as first type");
public:
    explicit OtherType(T1 t1, T2 t2)
        : mT1{ std::move(t1) }
        , mT2{ std::move(t2) }
    {
    }

private:
    T1 mT1;
    T2 mT2;
};
模板
结构安装:std::false\u类型
{
};
模板
结构安装:std::true\u类型
{
};
模板
类SomeType{};
模板
类其他类型
{
静态断言(IsInstantiation::value)||
IsInstallation::value,
“事件必须具有SomeType或OtherType作为第一个类型”);
公众:
显式OtherType(T1,T2)
:mT1{std::move(t1)}
,mT2{std::move(t2)}
{
}
私人:
T1-mT1;
T2-mT2;
};
尝试使用

template <typename, typename>
class OtherType;

template <typename T1, typename T2>
using OtherTypeAlias = OtherType<T1, T2>;

template <typename T1, typename T2>
class OtherType
{
    static_assert(IsInstantiation<SomeType, T1>::value ||
        IsInstantiation<OtherTypeAlias, T1>::value,
        "Event must have SomeType or OtherType as first type");

没有别名

哪一个是“第二次使用”?你能记下来吗?巴里已经大大改进了我的答案。只要写下
::OtherType
@Barry-我不知道的那篇文章(但我不得不想象);谢谢,这是一个错误。根据[temp.local]/1,注入的类名应被视为在此上下文中引用了类模板。@T.C.-Sorry;不太明白;你的意思是问题中的代码是正确的,并且是有缺陷的VS2015(还有我的clang++)?是的,@T.C.意味着符合要求的编译器应该接受你的原始程序。()
template <typename T1, typename T2>
class OtherType
{
    static_assert(IsInstantiation<SomeType, T1>::value ||
        IsInstantiation<::OtherType, T1>::value,
        "Event must have SomeType or OtherType as first type");