template-argument-deduction

template-argument-deduction

文章 0 浏览 6

为什么不能在`std::reference_wrapper`中推导模板实例?

假设我有一些 T 类型的对象,并且我想将其放入引用包装器中: int a = 5, b = 7; std::reference_wrapper p(a), q(b); // or "auto p = std::ref(a)" …

妞丶爷亲个 2024-12-21 01:50:28 5 0

是否可以在不编译失败的情况下推断类型是否不完整?

我想实现像 sizeof(complete_type) 这样的行为,将返回实际的 sizeof,而 sizeof(incomplete_type) - 将仅为 0 我需要它为 IPC(进程间)通信提供扩展…

向地狱狂奔 2024-12-20 19:40:44 5 0

非推导上下文中模板参数推导的解决方法

考虑以下代码: #include template struct outer { struct inner {}; }; template std::ostream& operator<<(std::ostream & stream, typename outer:…

温柔女人霸气范 2024-12-18 13:04:33 4 0

为什么不能从 Template::Type 推导出 T?

这段代码有什么问题? #include template struct TMap { typedef std::map Type; }; template T test(typename TMap::Type &tmap_) { return 0.0; } i…

江城子 2024-11-09 03:58:47 9 0

C++使用 shared_ptr 到 const T 的模板实例化

假设我有一个类 template class A { public: template void f(std::tr1::shared_ptr > v1, std::tr1::shared_ptr > v2) {} }; 以下内容无法编译: A a…

旧人九事 2024-10-31 06:33:50 11 0

具有未推断上下文的函数模板的部分排序

在阅读另一个问题时,我遇到了部分排序的问题,我将其简化为以下测试用例 template struct Const { typedef void type; }; template void f(T, typena…

苏别ゝ 2024-07-27 18:49:57 19 0
更多

推荐作者

梦断已成空

文章 0 评论 0

瞎闹

文章 0 评论 0

寄意

文章 0 评论 0

似梦非梦

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文