当前位置: 首页 > wzjs >正文

名字设计签名免费网站搜索引擎优化

名字设计签名免费,网站搜索引擎优化,南京网站制作电话,百度短链接转化器## 问题描述 两个结构几乎相同的模板实现&#xff0c;一个能正常工作&#xff0c;另一个在 VS2019 和 GCC 中都会报错。 ## 最小化测试代码 // bug_report.cpp #include <type_traits> #include <string>template<typename T> struct Type2Type { using t…

## 问题描述

两个结构几乎相同的模板实现,一个能正常工作,另一个在 VS2019 和 GCC 中都会报错。

## 最小化测试代码

// bug_report.cpp
#include <type_traits>
#include <string>template<typename T> struct Type2Type { using type = T; };
template<typename T1, typename T2> struct IsSameType : std::false_type {};
template<typename T> struct IsSameType<T, T> : std::true_type {};// 工作正常的版本
template<size_t idx, typename TList> struct FindNthTypeInTypeList;
template<typename T, template <typename ...> class TList, typename ... Types>
struct FindNthTypeInTypeList<0,TList<T, Types...>> : public Type2Type<T> {};
template<size_t idx, template <typename ...> class TList, typename T, typename ... Types>
struct FindNthTypeInTypeList<idx, TList<T, Types ...>> : public FindNthTypeInTypeList<idx-1, TList<Types ...>> {};
template<size_t idx, typename TList> using FindNthTypeInTypeList_t = typename FindNthTypeInTypeList<idx, TList>::type;// 不能工作的版本
template<size_t idx, typename TList> struct GetAllTypesFromIdx;
template<template <typename ...> class TList, typename ... Types>
struct GetAllTypesFromIdx<0, TList<Types...>> : public Type2Type<TList<Types...>> {};
template<size_t idx, typename T, template <typename ...> class TList, typename ... Types>
struct GetAllTypesFromIdx<idx, TList<T, Types...>> : public GetAllTypesFromIdx<idx-1, TList<Types...>> {};
template<size_t idx, typename TList> using GetAllTypesFromIdx_t = typename GetAllTypesFromIdx<idx, TList>::type;// 测试类型列表
template<typename...> struct TypeList {};
using tc_typeList = TypeList<int, char, std::string, char*>;int main()
{// FindNthTypeInTypeList 测试 - 这些都能工作static_assert(IsSameType<FindNthTypeInTypeList_t<0, tc_typeList>, int>::value);static_assert(IsSameType<FindNthTypeInTypeList_t<1, tc_typeList>, char>::value);static_assert(IsSameType<FindNthTypeInTypeList_t<2, tc_typeList>, std::string>::value);static_assert(IsSameType<FindNthTypeInTypeList_t<3, tc_typeList>, char*>::value);static_assert(!IsSameType<FindNthTypeInTypeList_t<0, tc_typeList>, char>::value);// GetAllTypesFromIdx 测试 - 这些会报错static_assert(IsSameType<GetAllTypesFromIdx_t<0, tc_typeList>, TypeList<int, char, std::string, char*>>::value);// static_assert(IsSameType<GetAllTypesFromIdx_t<1, tc_typeList>, TypeList<char, std::string, char*>>::value);// static_assert(IsSameType<GetAllTypesFromIdx_t<2, tc_typeList>, TypeList<std::string, char*>>::value);// static_assert(IsSameType<GetAllTypesFromIdx_t<3, tc_typeList>, TypeList<char*>>::value);
}

## 错误信息

在 VS2019 和 GCC 中都会报错:
 

1>C:\...\MiniMPL\sources\UnitTest\UT_MiniMPL\src\tc_typeList_cpp11.cpp(135,9): error C2752: 'MiniMPL::GetAllTypesFromIdx<0,UnitTest::tc_typeList>': more than one partial specialization matches the template argument list
1>C:\...\MiniMPL\sources\MiniMPL\include\MiniMPL\typeList_cpp11.hpp(56,105): message : could be 'MiniMPL::GetAllTypesFromIdx<0,TList<Types...>>'
1>C:\...\MiniMPL\sources\MiniMPL\include\MiniMPL\typeList_cpp11.hpp(58,105): message : or       'MiniMPL::GetAllTypesFromIdx<idx,TList<T,Types...>>'
1>C:\...\MiniMPL\sources\UnitTest\UT_MiniMPL\src\tc_typeList_cpp11.cpp(135): message : see reference to alias template instantiation 'MiniMPL::GetAllTypesFromIdx_t<0,UnitTest::tc_typeList>' being compiled
1>C:\...\MiniMPL\sources\MiniMPL\include\MiniMPL\typeList_cpp11.hpp(59,176): error C2794: 'type': is not a member of any direct or indirect base class of 'MiniMPL::GetAllTypesFromIdx<0,UnitTest::tc_typeList>'
1>C:\...\MiniMPL\sources\UnitTest\UT_MiniMPL\src\tc_typeList_cpp11.cpp(135,9): error C2938: 'MiniMPL::GetAllTypesFromIdx_t' : Failed to specialize alias template

## 问题分析

1. 两个模板实现 `FindNthTypeInTypeList` 和 `GetAllTypesFromIdx` 的结构几乎完全相同

2. 它们都有:

   - 一个 `idx=0` 的特化

   - 一个通用的递归特化

   - 相同的类型列表处理方式

3. `FindNthTypeInTypeList` 能正常工作,所有测试都通过

4. `GetAllTypesFromIdx` 在 VS2019 和 GCC 中都会报错

## 预期行为

- 两个模板都应该能正常工作

- `FindNthTypeInTypeList` 应该返回指定索引的类型

- `GetAllTypesFromIdx` 应该返回从指定索引开始的所有类型

## 实际行为

- `FindNthTypeInTypeList` 按预期工作

- `GetAllTypesFromIdx` 报错,认为两个特化是同等特化的

## 环境信息

- 编译器:VS2019 和 GCC

- 标准:C++11 或更高

- 操作系统:Windows/Linux

## 可能的解决方案

1. 使用 SFINAE 来限制第二个特化只在 `idx>0` 时匹配

2. 重新设计模板特化,使其特化规则更明确

3. 等待编译器更新修复这个 bug

http://www.dtcms.com/wzjs/274001.html

相关文章:

  • 网站翻新后seo怎么做竞价推广课程
  • 网站建设与技术团队互联网营销师培训
  • 网站平台流量购买网站
  • 网站建设与网站优化磁力搜索器
  • wordpress文章留言网站seo 优化
  • 嘉兴网站制作建设淘宝seo软件
  • 时尚网站网页设计上海还能推seo吗
  • 管理软件开发公司杭州网站优化企业
  • 平顶山做网站优化广州seo网站
  • 上海怎么做网站北京seo服务行者
  • 如何做百度搜索推广seo短视频保密路线
  • 做刀模网站推广软文发布平台
  • 公司做网站的费用怎么入账列举网络推广的方式
  • 广告设计毕业设计优化师助理
  • 建行app怎么注册登录网站自然优化
  • 免费自己建立网站百度指数快刷软件
  • 民法典建设工程施工合同国内好的seo网站
  • 如何用ps做网站设计图网站在线客服系统免费
  • 山西 网站制作114网址大全
  • 聊天系统源码北京seo排名服务
  • 做网站买那种服务器好百度推广怎么注册账号
  • 做视频大赛推广的网站百度关键词挖掘工具爱站网
  • 大连市政府网站建设规定怎么做谷歌推广
  • 建站视频百度查重
  • 怎么做asp网站汕头网站设计公司
  • wordpress自定义文章添加标签seo优化及推广如何运营
  • 北京网站公司哪家好快手刷粉网站推广
  • app软件开发定义惠州seo报价
  • 四川省建设工程设备安全协会网站长春百度seo公司
  • 网站开发项目经理主要工作广州seo优化外包公司