我写了一些在最新版本的 GCC 和 Clang 上编译良好的代码,但在 MSVC 上失败了:
模板参数“TL”的模板参数无效,应为类模板
谁能解释一下这是一个错误还是我误解了什么?
如果没有部分专业化,types_list它也可以在 MSVC 上正常工作。
#include <cstdint>
#include <type_traits>
namespace detail
{
template <std::size_t Index, typename ...Ts>
struct get
{
static_assert(Index < sizeof...(Ts), "types_list::get index out of bounds");
private:
template <std::size_t CurrentIndex, typename ...Us>
struct helper
{
using type = void;
};
template <std::size_t CurrentIndex, typename U, typename ...Us>
struct helper<CurrentIndex, U, Us...>
{
using type = std::conditional_t<CurrentIndex == Index, U, typename helper<CurrentIndex + 1, Us...>::type>;
};
public:
using type = …Run Code Online (Sandbox Code Playgroud)