Questions tagged «type-deduction»

3
什么时候类型信息在C ++中向后流动?
我刚刚看了斯蒂芬·拉瓦维(Stephan T. Lavavej)在CppCon 2018“类模板参数推论”上的讲话,在某个时候他偶然说: 在C ++类型的信息中,信息几乎永远不会倒退…… 我不得不说“几乎”,因为只有一两种情况,可能更多但很少。 尽管试图弄清楚他可能指的是哪种情况,但我什么也没想出来。因此,问题是: 在哪种情况下,C ++ 17标准要求类型信息向后传播?

2
不同C ++编译器之间的自动类型推导不匹配
因此,我试图以某种现代C ++的形式实现点积(https://en.wikipedia.org/wiki/Dot_product),并提出了以下代码: #include <iostream> template<class... Args> auto dot(Args... args) { auto a = [args...](Args...) { return [=](auto... brgs) { static_assert(sizeof...(args) == sizeof...(brgs)); auto v1 = {args...}, i1 = v1.begin(); auto v2 = {brgs...}, i2 = v2.begin(); typename std::common_type<Args...>::type s = 0; while( i1 != v1.end() && i2!= v2.end()) { s …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.