Questions tagged «template-templates»


1
可以将变量模板作为模板模板参数传递吗?
以下荒谬的示例无法编译,但是还有其他方法可以将变量模板作为模板模板参数传递吗? template<typename T> constexpr auto zero = T{0}; template<typename T, template<typename> auto VariableTemplate> constexpr auto add_one() { return VariableTemplate<T> + T{1}; } int main() { return add_one<int, zero>(); } 尝试编译器资源管理器

2
C ++模板模板参数类型推导
我有在字符串容器中查找并打印出模式匹配项的代码。在模板化的函数foo中执行打印 编码 #include <iostream> #include <algorithm> #include <iterator> #include <vector> #include <string> #include <tuple> #include <utility> template<typename Iterator, template<typename> class Container> void foo(Iterator first, Container<std::pair<Iterator, Iterator>> const &findings) { for (auto const &finding : findings) { std::cout << "pos = " << std::distance(first, finding.first) << " "; std::copy(finding.first, finding.second, std::ostream_iterator<char>(std::cout)); …
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.