【发布时间】:2017-10-06 16:43:44
【问题描述】:
考虑一个例子:
#include <type_traits>
#include <string>
template <template <class> class TT> //#1
struct Foo {
static void foo() {
static_assert(std::is_same_v<decltype(TT("abc")), TT<std::string>>);
}
};
template <class T>
struct Bar {
Bar(T) {}
};
template <class T>
Bar(T) -> Bar<std::string>; //#2
int main() {
Foo<Bar>::foo();
}
[clang] 和[gcc] 在推导模板模板参数(#1)的模板参数时,似乎都使用了用户提供的推导指南(#2)。它是符合标准的功能吗?
【问题讨论】:
标签: c++ templates language-lawyer c++17 template-argument-deduction