C++ 调试函数的优化代码(带模板的c+;+;11)
我创建了这个调试“函数”,但不知道如何使用模板。所以我想知道是否有更简单的方法来获得同样的结果。如果有人知道我不知道的任何函数可以帮助我,请告诉我。如果你需要帮助去理解一些事情,只要问:)C++ 调试函数的优化代码(带模板的c+;+;11),c++,function,templates,c++11,optimization,C++,Function,Templates,C++11,Optimization,我创建了这个调试“函数”,但不知道如何使用模板。所以我想知道是否有更简单的方法来获得同样的结果。如果有人知道我不知道的任何函数可以帮助我,请告诉我。如果你需要帮助去理解一些事情,只要问:) //容器 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 //输入/输出 #包括 //其他 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #包括 #
//容器
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
//输入/输出
#包括
//其他
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
#包括
使用名称空间std;
模板结构F22{};
//其他(仅剩下地图)
模板
结构F22{
模板
静态void F23(字符串名称,ta){
自动t=a;
int i=0;
对于(自动it=t.begin();it!=t.end();+it)
cout firststd::forward_list::max_size
返回forward_list容器可以容纳的最大元素数
您的转发列表实施应为:
//Forward list
template<>
struct F22<true>{
template<typename T>
static void F23(const string& name, const T& a){
std::size_t i = 0;
for (const auto& e : a) {
std::cout << name << "[" << i << "]: " << e << std::endl;
++i;
}
}
};
//转发列表
模板
结构F22{
模板
静态无效F23(常量字符串和名称,常量T和a){
标准:尺寸i=0;
用于(施工自动和电气:a){
std::cout可能描述debug()的预期行为
可能会有帮助……请直观地描述各个函数的作用。@sfrehse:what?FN
,anda
,b
,c
,d
,这些都不是自解释的。这个问题似乎是离题的,因为它是关于在没有任何合理解释的情况下粘贴数百行代码
//Forward list
template<>
struct F22<true>{
template<typename T>
static void F23(const string& name, const T& a){
std::size_t i = 0;
for (const auto& e : a) {
std::cout << name << "[" << i << "]: " << e << std::endl;
++i;
}
}
};