Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 请帮我解读STL自动完成建议_C++_Templates_Stl - Fatal编程技术网

C++ 请帮我解读STL自动完成建议

C++ 请帮我解读STL自动完成建议,c++,templates,stl,C++,Templates,Stl,我使用MSVC和STL,与之相比,它给出的自动完成建议让我感到悲伤。对于std::transform函数,您能否打破这个建议 _OutTy * transform<_InIt1, _InTy, _InSize, _OutTy, _OutSize, _Fn2> (_InIt1 _First1, _InIt1 _Last1, _InTy (&_First2)[_InSize], _OutTy(&_Dest)[_OutSize], _Fn2 _Func) \u OutTy

我使用MSVC和STL,与之相比,它给出的自动完成建议让我感到悲伤。对于
std::transform
函数,您能否打破这个建议

_OutTy * transform<_InIt1, _InTy, _InSize, _OutTy, _OutSize, _Fn2>
(_InIt1 _First1, _InIt1 _Last1, _InTy (&_First2)[_InSize], _OutTy(&_Dest)[_OutSize], _Fn2 _Func)
\u OutTy*变换
(初始1、初始1、初始1、初始2、初始1、初始2、初始1、初始1、初始2、初始1、初始1、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、初始2、

编辑:对不起,我应该说得更清楚些。我看到了转换的文档。我想有人把上面句子中的各种符号分解一下


谢谢。

将cplusplus.com的参考资料更新为cppreference.com

template
输出迭代器转换(先输入迭代器1,
输入计数器1 last1,
输入计数器2 first2,
输出者d_优先,
二进制操作(二进制操作);
参数
  • first1,last1-要转换的第一个元素范围
  • first2-要转换的第二个元素范围的开始
  • d_first-目标范围的开始,可能等于first1或first2
  • 二进制\u op-将应用的二进制操作函数对象。 函数的签名应等同于以下内容:
    Ret-fun(常数类型1&a、常数类型2&b)
    签名不需要有常量&。
    类型Type1和Type2必须使类型InputIterator1和InputIterator2的对象可以被取消引用,然后分别隐式转换为Type1和Type2。Ret类型必须使OutputIterator类型的对象可以取消引用并分配Ret类型的值。​
    
返回值
  • 将迭代器输出到经过最后一个元素转换的元素

希望对您有所帮助

将cplusplus.com的参考资料更新为cppreference.com

template
输出迭代器转换(先输入迭代器1,
输入计数器1 last1,
输入计数器2 first2,
输出者d_优先,
二进制操作(二进制操作);
参数
  • first1,last1-要转换的第一个元素范围
  • first2-要转换的第二个元素范围的开始
  • d_first-目标范围的开始,可能等于first1或first2
  • 二进制\u op-将应用的二进制操作函数对象。 函数的签名应等同于以下内容:
    Ret-fun(常数类型1&a、常数类型2&b)
    签名不需要有常量&。
    类型Type1和Type2必须使类型InputIterator1和InputIterator2的对象可以被取消引用,然后分别隐式转换为Type1和Type2。Ret类型必须使OutputIterator类型的对象可以取消引用并分配Ret类型的值。​
    
返回值
  • 将迭代器输出到经过最后一个元素转换的元素

希望帮助

事实上C++智能有时候是一种痛苦。因此,我建议点击F1或在MSDN上搜索std::transform:wich给出以下解释:

_First1
    An input iterator addressing the position of the first element in the first source range to be operated on.
_Last1
    An input iterator addressing the position one past the final element in the first source range operated on.
_First2
    An input iterator addressing the position of the first element in the second source range to be operated on.
_Result
    An output iterator addressing the position of the first element in the destination range.
_Func
    User-defined unary function object used in the first version of the algorithm that is applied to each element in the first source range or A user-defined (UD) binary function object used in the second version of the algorithm that is applied pairwise, in a forward order, to the two source ranges. 

事实上,C++智能有时候是一种痛苦。因此,我建议点击F1或在MSDN上搜索std::transform:wich给出以下解释:

_First1
    An input iterator addressing the position of the first element in the first source range to be operated on.
_Last1
    An input iterator addressing the position one past the final element in the first source range operated on.
_First2
    An input iterator addressing the position of the first element in the second source range to be operated on.
_Result
    An output iterator addressing the position of the first element in the destination range.
_Func
    User-defined unary function object used in the first version of the algorithm that is applied to each element in the first source range or A user-defined (UD) binary function object used in the second version of the algorithm that is applied pairwise, in a forward order, to the two source ranges. 

建议的重载是对第3个和第4个参数都是数组的情况的专门化<代码>\u InTy(&\u First2)[\u InSize]
更具可读性,因为
InType(&Second)[InputLength]
,即
Second
是对
InType[InputLength]
类型数组的引用

这种专门化的优点是编译器知道第二个输入序列的长度。主重载只有一个模板化的
inputierator BeginOfSecond
参数,但没有
EndOfSecond
参数


类似地,
\u OutTy(&\u Dest)[\u OutSize]
允许编译器检测输出序列的长度(如果是数组)。

建议的重载是针对第三个和第四个参数都是数组的情况的专门化<代码>\u InTy(&\u First2)[\u InSize]
更具可读性,因为
InType(&Second)[InputLength]
,即
Second
是对
InType[InputLength]
类型数组的引用

_OutTy* // output type   
transform<_InIt1, // input iterator type for first range
          _InTy, _InSize, // input and size type for second range (array)
          _OutTy, _OutSize, // output and size type for output range (array)
          _Fn2> // transformation function object type
(_InIt1 _First1, _InIt1 _Last1, // first and last iterators for first range
 _InTy (&_First2)[_InSize], // array for second range
 _OutTy(&_Dest)[_OutSize], // array for output range
 _Fn2 _Func) // transformation function object
这种专门化的优点是编译器知道第二个输入序列的长度。主重载只有一个模板化的
inputierator BeginOfSecond
参数,但没有
EndOfSecond
参数

类似地,
\u OutTy(&\u Dest)[\u OutSize]
允许编译器检测输出序列的长度(如果是数组)。

\u OutTy*//输出类型
_OutTy* // output type   
transform<_InIt1, // input iterator type for first range
          _InTy, _InSize, // input and size type for second range (array)
          _OutTy, _OutSize, // output and size type for output range (array)
          _Fn2> // transformation function object type
(_InIt1 _First1, _InIt1 _Last1, // first and last iterators for first range
 _InTy (&_First2)[_InSize], // array for second range
 _OutTy(&_Dest)[_OutSize], // array for output range
 _Fn2 _Func) // transformation function object
变换//变换函数对象类型 (_InIt1 _First1,_InIt1 _Last1,//第一个范围的第一个和最后一个迭代器 _InTy(&_First2)[[u InSize],//第二范围的数组 _OutTy(&_Dest)[_OutSize],//用于输出范围的数组 _Fn2 _Func)//变换函数对象
我的建议是:不要浪费时间做这件事。我自己花了好几分钟才把它搞定,我已经习惯了这种东西。按照其他帖子中的建议快速访问文档

如果您想解密MSVC的C++库实现,那么查看它们的头文件,而不仅仅是智能感知。您将学习他们使用的一些常见约定,如

InIt